Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / what is the equivalent in OpenGL of DirectX concept of a shader technique in HLSL

Author
Message
Scorpius
7
Years of Service
User Offline
Joined: 16th Feb 2017
Playing: Malevolence: Sword of Ahkranox, Skyrim, Civ6
Posted: 25th Dec 2018 12:34
Hi All,

I've started dabbling with AppGameKit (at long last ) and I have to say I'm impressed. It seems to have come a long way since it first started and compares very favourably on Windows PCs with DBPro (which till now has been my language of choice). The language and editor are both much easier to use and less buggy (although I have noticed a few oddities/bugs in each - although I've refrained from posting anything about them till I have more experience of using both).

I like the shader support which is generally good and clear but I'm not sure of the best way to emulate the concept of shader techniques which I used to use extensively in DBPro. I can see two obvious options: one is to write a separate shader for each one and just switch shader when I need a different technique; a second option is to use a Boolean flag or flags to switch in the shader itself. Can someone give me advice on the best way to go? For example, is there a more direct option that I have missed?

Season's Greetings and Happy Xmas to everyone here .
Scorpius of the Malevolence:Sword of Ahkranox forums aka Green Gandalf of the TGC forums.
Shader developer for Evochron Legacy produced by StarWraith 3D games.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 25th Dec 2018 14:50
I may be very wrong here, but don't DBPro and agk use completely different technologies? DBPro was direct x, agk is open gl........so the shaders aren't compatible, fairly sure you'll need two seperate shaders.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Dec 2018 16:35
I think you'll see that is implied by the title of the thread. Yes, they are quite different - on the surface anyway, I don't know about the low-level compiled forms of the shaders though. Hence the question.

If you really need two separate shaders then that is fine as long as there are no significant performance downsides to doing things that way, i.e. things like memory leaks, shader/object setup times, etc, etc. I'll report back when I've done some further testing .
Green Gandalf of the TGC forums aka Scorpius of the Malevolence:Sword of Ahkranox forums.
Shader developer for Evochron Legacy produced by StarWraith 3D Games.
Santman
13
Years of Service
User Offline
Joined: 15th Sep 2011
Location: Inverness
Posted: 25th Dec 2018 18:26
Yes, but I'll also think you'll see the question was asked if you could use a flat or had to write two seperate shaders, which I answered. The question wasn't clear though, why would you switch between a shader for agk and a shader for DBPro... why would you write the same thing for each? That made no sense.

Good luck though, sure you'll suss it out.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Dec 2018 19:10
I asked this:

Quote: "I like the shader support which is generally good and clear but I'm not sure of the best way to emulate the concept of shader techniques which I used to use extensively in DBPro. I can see two obvious options: one is to write a separate shader for each one and just switch shader when I need a different technique; a second option is to use a Boolean flag or flags to switch in the shader itself. Can someone give me advice on the best way to go? For example, is there a more direct option that I have missed?"


It should be clear that I was asking about switching between OpenGL shaders in AppGameKit not between HLSL and GLSL shaders which is obviously a non-starter. Anyway, we seem to be agreed on one way to go. So I'll see how it turns out.

In case there's any more confusion, I inadvertently posted this thread using my other account (Scorpius). I'll have to be more careful as I've done that a few times recently .

Quote: "Good luck though, sure you'll suss it out."


Thanks. I hope so.
Green Gandalf of the TGC forums aka Scorpius of the Malevolence:Sword of Ahkranox forums.
Shader developer for Evochron Legacy produced by StarWraith 3D Games.
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 30th Dec 2018 11:11 Edited at: 30th Dec 2018 11:12
Hi Green Gandalf I remember you from my DBpro times
There are a few ways to switch between shader effects.
1. use preprocessor variables (#define A=true,#ifdef A=true) doesn't work in runtime (you can also generate them into the shader code)
2. use uniforms AppGameKit only allows for floats right now but I guess you can still abuse the bits for boolean operations for a normal if clause
3. create one shader that does what you want in every situation using math (may not work for complex shaders or performance will suffer)
4. just create different shader for it (not sure if switching between shaders does have "huge" impact on performance)
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Dec 2018 10:09
Hi Janbo,

Thanks for posting . I am finding your shader pack very helpful. I have tried all of your suggestions except the first. They all seem to work well but I don’t yet know which is the best way to do it. One thing that does seem easier in AppGameKit is switching between shaders - I am fairly sure that caused all sorts of difficulties in DBPro and the preferred method was switching between techniques. I’m hoping to have some useful demos to post in due course.

I also like the way the rendering cycle can be broken down into its components - although I have noticed a few oddities. For example, I can’t see the point of the DrawText command - it doesn’t seem to work as stated in the Help file (I might have missed something though - I was expecting it to work in exactly the same way as the DrawObject and DrawSprite commands). Of course, the extra flexibility has its downside - it took me an embarrassingly long time to spot that I had placed a ClearScreen command immediately before a SetRenderToImage command instead of immediately after .
Green Gandalf of the TGC forums aka Scorpius of the Malevolence:Sword of Ahkranox forums.
Shader developer for Evochron Legacy produced by StarWraith 3D Games.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Jan 2019 13:47
Quote: "For example, I can’t see the point of the DrawText command - it doesn’t seem to work as stated in the Help file (I might have missed something though - I was expecting it to work in exactly the same way as the DrawObject and DrawSprite commands)."


Oops! Just finished testing this again and it does work as intended and described in the Help file after all . I think I must have had a stray SetTextVisible(ID, 0) in my original code .


So, good news all round .

Happy New Year to you all.
Green Gandalf of the TGC forums aka Scorpius of the Malevolence:Sword of Ahkranox forums.
Shader developer for Evochron Legacy produced by StarWraith 3D Games.

Login to post a reply

Server time is: 2024-11-23 08:41:18
Your offset time is: 2024-11-23 08:41:18