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 Studio Chat / Specular or Shininess

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Mar 2020 01:19
Is there anyway to implement specular or shininess with a model?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 27th Mar 2020 06:03
I believe it has to be done with a shader ive had a bit of a go at producing that in a shader
but with my limited knowledge of shaders had limited success

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 27th Mar 2020 06:42 Edited at: 27th Mar 2020 08:11
I think you mean something like this https://stackoverflow.com/questions/11794277/glsl-shader-for-glossy-specular-reflections-on-an-cubemapped-surface
some of those glsl commands might require the latest version but thinking they should work with studio

The problem I have im unsure how I get gl_ModelViewProjectionMatrix and gl_Vertex;
from the following

and if its a glow you want https://forum.thegamecreators.com/thread/222027?page=2 which I got help finalizing from santman

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 27th Mar 2020 13:23 Edited at: 27th Mar 2020 13:27
Depends on what you're looking for exactly.
By Default AppGameKit initialises it's Default Light in Vertex Lighting Mode... switching to Pixel Lighting will result in the Default Blinn-Phong adding "Shininess" to the Output... but it's very Basic.
Are you looking for a way to specifically add a "Specular" Term., as in a Specular Image Map that can be used to define how Shiny a Surface is?

As for some reason TGC have simply forgotten about allowing a Specular Component (DBP supported it, weird AppGameKit doesn't) ... you can craft a Shader that support it.
Of course, and this is something that actually frustrates me a little... there are no default Light Inputs to Shaders.

That is to say that AppGameKit doesn't automatically push Lighting Data to Shaders, instead it handles it in a procedurally generated Black Box Function.
And what's worse is the Light Commands don't actually allow you to simply use AGK's Light Framework to GET any information.
So, you essentially have to program an entire Light Framework yourself... then push them into the Shader.



Now this will work with the Default Vertex Shader... (you can grab it from the help files)
It only supports 1 Light Source, but it supports a Specular Map.



Now I've attached some example media ... I'm using bricks2_disp.jpg in the example because it best showcases the effect, but wood_s will provide a more "Realistic" example.
Oh forgot to say, if you want just a "Blanket" Specular effect, then just use the CreateImage( ) Function to make a solid colour... now I am just doing this "Rough-and-Ready", so it isn't really inputting a Greyscale and using that; plus I'm not actually handling the Colour output so it more or less is just a White Specular Term.

If it is what you're looking for though, I can expand upon it to be more Plug-and-Play as a Full Shader; adding support for Colour, Normal and adding support for multiple light sources (with and AppGameKit Source to make that easier as well)
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 27th Mar 2020 13:52
Its not too hard really:
https://forum.thegamecreators.com/thread/221784#msg2621472

It might just be as easy to to use janbos specular shader if you have the shader pack. Alternatively you can use the PBR shader that comes with AppGameKit but that is probably way more complicated then what you need (and features loads more inputs than just colour and specular).

It is possible to get at the AppGameKit light values from within a shader if you wanted to - they just aren't documented in the shader guide. Probably best to pass your own anyway so you are not limited to 8 lights and you can pass more info like the specular amounts and powers etc...
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Mar 2020 22:52 Edited at: 28th Mar 2020 00:17
Ok. Thanks everyone. I will look into those things

Quote: "Now I've attached some example media "


I don't think the attach worked
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th Mar 2020 00:23 Edited at: 28th Mar 2020 00:25
Quote: "That is to say that AppGameKit doesn't automatically push Lighting Data to Shaders, instead it handles it in a procedurally generated Black Box Function.
And what's worse is the Light Commands don't actually allow you to simply use AGK's Light Framework to GET any information.
So, you essentially have to program an entire Light Framework yourself... then push them into the Shader."


YES ! I couldn´t have said it better myself.
It's all there, I guess they just have to check if the uniform agk_PSLight for example is already there and use it instead, and if not, generate it.
And they should make an array out of it instead of generating the uniform name agk_PSLight1Pos.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Mar 2020 00:24
Will your shaders do specular janbo?
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 28th Mar 2020 00:25
there is a awesome shader called pbr that comes with agks same stuff big engines use.

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th Mar 2020 00:31 Edited at: 28th Mar 2020 00:38
@blink0k
Yes, the Specular shaders produce specular highlights using a DualParabolic or Screenspace map of the environmap.
So they do a bit more than the classic specular shader.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 28th Mar 2020 00:33
I am lucky enough to own the shader pack and trying to learn so as I don't just copy code from it
using this example online [href]https://en.wikipedia.org/wiki/Blinn–Phong_reflection_model[/href]

I converted to


I suspect the problem is with these variables mat4 agk_Proj, agk_View, agk_WorldNormal; which I changed from projection * modelview and normalMat
I just get total blackness. There may be commands missing that are compulsory aswell any ideas would be greatly appreciated.

And raven that looks great im going to have to try that next

fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Mar 2020 00:34 Edited at: 28th Mar 2020 00:45
What are the parameters for
SP_Specular_AddObject(ObjectID,DiffuseImageID,NormalImageID,SpecularImageID,EnvironmentID)

Does NormalImageID mean i need a normal map?

Does SpecularImageID mean i need a specular map?

What is the EnvironmentID?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 28th Mar 2020 00:40 Edited at: 28th Mar 2020 00:43
Quote: "Does NormalImageID mean i need a normal map?"

Yes
Quote: "Does SpecularImageID mean i need a specular map?"

Sort of, you want a specular map in the Red channel and a roughness map in the Green channel, it's like a pseudo PBR shader

If you want it without Environment mapping then toss me a PM.
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 28th Mar 2020 01:45
Quote: "I don't think the attach worked"


Well I just checked and it says "Your Files are Uploaded and should show shortly...", I'm sure I posted like 8 hrs ago now (c'mon forum hamsters!)
Still just in case, here's some other files to play with.

Diffuse


Specular


Normal


Maybe embedding speeds things up

Quote: "I suspect the problem is with these variables mat4 agk_Proj, agk_View, agk_WorldNormal; which I changed from projection * modelview and normalMat
I just get total blackness. There may be commands missing that are compulsory aswell any ideas would be greatly appreciated."


You have to use specific attribute names, as you can't rebind / custom bind new ones.
i.e.
position (vertex position)
uv (uv set 0)
uv1 (uv set 1)
...
uv8 (uv set 8)
color (vertex colour, but this doesn't actually work... I mean it does and doesn't., not sure what they have attached to it; but you'll want to use uniform vec4 agk_MeshColor; instead)
tangent
bitangent
etc.

...

As a note in GLSL

attribute = model data
varying (which you can also use 'out' and 'in') means "Passed Data" ... so anything you want to declare in the Vertex / Geometry / Compute / Pixel Shader and want to pass on to the next stage
uniform = input data (this is anything you set with "SetShaderConstantByName" or AppGameKit itself is automatically binding)
const = unchanging data, a bit like #constant in AGK

There's actually a lot of weird rules and limitations to AppGameKit' implementation of GLSL., most of which I have a feeling stem from the focus to support OpenGL ES 1.1 first and anything else is more-or-less a "Bonus"
Still the one that has me scratching my head is no support for Integers.
Like the Shader Code itself (the functions you run on the GPU), have zero issues declaring and using them; but anything AppGameKit has control over and it simply says "No"
So if you do need Integers (which can be useful for flags, branching code, etc.), then declare them as a uniform float and then just int( ) typecast when you need to use them... I tend to declare a local int, as in int myValue = int( uniformValue );
then just use the internally declared one.

Also, unless you're converting from SRGB to Linear (which you're not)... don't convert from Linear to SRGB ("Gamma Corrected Colour") when you output, as AppGameKit is natively using SRGB as the Input / Output; so you don't need to correct as it'll be in the correct Colour Space already
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 28th Mar 2020 04:44
Annoying when you can't sleep, so figured I'd tinker for a bit on improving the Shader a little ... just cleaned it up and added normal mapping.
Tinkered with the demo code a little and then got distracted with Substance :-\
Still added everything into a zip, so should make it a bit easier to just run it "As is" ... oh as a note because the AppGameKit IDE doesn't exactly support Shader Code; I'd recommend downloading Visual Code and installing the GLSL Extension (with Shader Preview Extension); makes tinkering with them much easier.

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th Mar 2020 05:30
Thank you!!
GaborD
6
Years of Service
User Offline
Joined: 3rd Dec 2017
Location:
Posted: 28th Mar 2020 12:27 Edited at: 29th Mar 2020 17:10
Quote: "It's all there, I guess they just have to check if the uniform agk_PSLight for example is already there and use it instead, and if not, generate it.
And they should make an array out of it instead of generating the uniform name agk_PSLight1Pos."


Fully agree.
Some engines (for example NB) also pushed an array of all the light matrices to shaders, made custom shadowmapping very easy.
I hope AppGameKit will fully move towards PBR at one point, would lessen the custom shader workload for smaller games.

I don't have much else to add, other than recommending Janbo's shader pack. It's great.

Login to post a reply

Server time is: 2024-03-28 09:23:51
Your offset time is: 2024-03-28 09:23:51