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 / Example for Sprite or Fullscreen shader

Author
Message
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 14th Nov 2014 20:48 Edited at: 14th Nov 2014 21:24
Hi folks,

all the examples of shader usage I saw in here and in the code samples load shaders via a vertex and pixel shader.

But there is LoadFullScreenShader and LoadSpriteShader. Do you know of any example so I can see how it is done?

What I am after is a simple bloom shading for my sprites and for a full screen sepia effect.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Nov 2014 14:40 Edited at: 18th Nov 2014 14:42
There is a bloom shader example with AGK. Just load the pixel shader without the need for the quad vertex shader in that example.

Here's a sepia shader for you... getting into these now:


EDIT: Attached example code too

Attachments

Login to view attachments
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 18th Nov 2014 17:11 Edited at: 18th Nov 2014 17:12
Thanks. So you say that the bloom shader should work with LoadSpriteShader alone? All the examples show always the usage with a vertex shader. Somehow I can't get this to work. Will check again. Thanks for the example. Will test later when I am home.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Nov 2014 20:21
The bloom shader should work fine as it is designed to be used with the quad object removing the need for the quad vertex shader. I tested it with my example and it works fine. Simplifies the code a little.
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 18th Nov 2014 22:17 Edited at: 18th Nov 2014 22:25
Ok,I was able to run your code. Two shaders reported errors but the sepia and another one ran. Thanks to that.

But I can't get the sprite shader to work int AGK2. Maybe I am not understanding the concept.

Here is the code:




Would be awesome if you could help me with that one.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Nov 2014 22:27
I would take a look at using a quad object for the bloom shader as shown in the example project. It's pretty complicated.

What error did you get with the other shaders?
MikeHart
AGK Bronze Backer
21
Years of Service
User Offline
Joined: 9th Jun 2003
Location:
Posted: 18th Nov 2014 23:00
With Loadshader and an according vertex shader I get things to work. Slowly I think that LoadSpriteShader is buggy. I try to find someone who can provide an example that works or shares my oppinion.

Attached is the screenshot of one error. The other shader has a similar error.

Attachments

Login to view attachments
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 19th Nov 2014 16:18 Edited at: 19th Nov 2014 16:20
Hi MikeHart,

Quote: " Slowly I think that LoadSpriteShader is buggy"

I can not confirm that, for me LoadSpriteShader works.
[AGKv2] 2D Normalmapping

You can't use a "3D shader" for LoadSpriteShader.
Im sure LoadSpriteShader loads a default vertex shader, so you have to setup your fragment shader for it
and I don't know how the vertex shader for the LoadFullScreenShader command looks like.

Your possibilities may be:
1. Write/Convert a Bloom shader(fragment) for Sprites and make the sprite fit the screen.
2. Write/Convert a Bloom shader(fragment) for LoadFullScreenShader..never seen an example of it.
3. Just use the Bloom shader(fragment and vertex) of the agk example with the quad object.
4. May be LoadSpriteShader is buggy and I had luck

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th Nov 2014 17:31
Quote: "Attached is the screenshot of one error. The other shader has a similar error."

I'm not sure how that can be the case... here is the code for the subtractive shader. It doesn't create any vec3 or vec4 directly just uses the texture2D which creates a vec4 in both cases (I believe). The only change here is that I found multiplying worked better than subtracting:

Login to post a reply

Server time is: 2024-11-25 11:35:46
Your offset time is: 2024-11-25 11:35:46