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.

DarkBASIC Professional Discussion / Am I Completely Missing Something (Shader Basics)

Author
Message
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 25th Jun 2013 07:04 Edited at: 25th Jun 2013 07:04
I've gone through all of the shader threads on here and haven't found out what I'm doing wrong. I've been trying to get into learning shaders and found some excellent tutorials online, but no matter what I try, every time I try to use the CREATE PIXEL SHADER FROM FILE command, I get an error message that says "vertex shader cannot be assembled." And I'm using very basic shaders that have been made by others so there's definitely nothing wrong with the .fx file.

I really wish the manual for DBPro went into this a little bit more, because the help file is useless on the subject of shaders.

And just so you can see, this is the simplest of the .fx files that I've been trying to use.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 25th Jun 2013 07:16
I'm on my mobile without access to the help files for reference. Try using the Load Effect command instead. Something like that. Anyway I'm pretty certain you are using the wrong command to load the shader.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 25th Jun 2013 07:23
Ohhhhhhh, that makes sense! I'll try that. Thank you so much!
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 25th Jun 2013 07:26
Success! You are awesome. Thank you!
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 25th Jun 2013 07:43
It's compiling but instead of creating ambient light it's turning the object invisible... I'm just going to have to do a lot of playing around with these this weekend!
James H
19
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 25th Jun 2013 14:37
Quote: " every time I try to use the CREATE PIXEL SHADER FROM FILE command, I get an error message that says "vertex shader cannot be assembled." And I'm using very basic shaders that have been made by others so there's definitely nothing wrong with the .fx file"

This command is for pixel shader only - a .psh file. There is also available the use of .vsh files for vertex shader only(the file extension might not be fixed as the help files say a text file but from memory the help files used to actually have examples for these commands along with .vsh / psh files so it might be worth testing for whatever reason). The .fx file combines both in 1 file. I havent tested but I ASSUME that you can mix vertex and pixel shaders(ie the way you first tried) at will using the seperate commands which might prove usefull or not - I don`t know enough about .fx to be able to say that you could choose to have all vertex and pixel shaders in the file and choose to mix them at will(maybe by setting different techniques). Perhaps someone who does know could comment further..
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jun 2013 15:08 Edited at: 25th Jun 2013 15:10
Wild wild guess looking at the shader file; it looks like your multiplying all colour channels by 0.1; which will also reduce its transparency presuming the object has transparency enabled; but I would have throught the object would look black since no alpha transparency has been enforced in the shader itself; IE: the ALPHABLENDENABLE = TRUE attribute.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jun 2013 18:47 Edited at: 25th Jun 2013 19:09
The object will probably be invisible because I guess you haven't passed the values of the three matrices to the shader. In DBPro the usual way is to use the standard semantics so instead of



you should use




Those "semantics" are needed so that DBPro knows that the thing called World in your shader is in fact the object's World matrix as calculated by DBPro. The other two are similar.

I usually use different names in my shader to avoid this sort of confusion. For example, I usually use the following



This makes clearer the distinction between the shader variable mW and the DBPro semantic World. You can use World for both if you prefer.

Edit I should have added that your shader works perfectly once the semantics have been added. Good luck with this.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Jun 2013 19:44 Edited at: 25th Jun 2013 19:44
It's good practice to use more spelled out variable names:



The reason being the many, many different states you can have in a shader. For example, "LightPosition" is still too vague. Is it in world space? View space? Projection space? Screen space? Is it a float3 or float4?

Because when I see things like the following:



I just feel like doing THIS to the programmer who wrote it...

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jun 2013 20:01
Sounds a bit over the top to me.
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 26th Jun 2013 00:32
Thanks for your help everyone. I'm going to play around with it more later when I've finished teaching summer school (this Thursday). It does seem like programming shaders is one of those things with a VERY steep learning curve, but once you get over that initial hump, it's not too bad. I think I'm going to have a lot of fun trying this out!
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2013 01:27 Edited at: 26th Jun 2013 01:31
If you have DarkShader, check this out: http://cpavts.wikispaces.com/file/view/Shaders_Beginners.pdf

If you really, really want to learn how to program shaders properly, I recommend checking out RenderMonkey.

This article gives you a solid overview of how the graphics card works, and what shaders to do it: http://duriansoftware.com/joe/An-intro-to-modern-OpenGL.-Chapter-1:-The-Graphics-Pipeline.html (yes, it's OpenGL, but at this level it doesn't matter yet)

Here's a tutorial on using RenderMonkey: http://www.david-gouveia.com/rendermonkey-beginners-tutorial/
Another, more in-depth tutorial for RenderMonkey: http://mirror.ati.com/developer/gdc/Tatarchuk-GDC03-Beginner_Shader_Programming_with_RenderMonkey.pdf

It's a terrifyingly steep mountain to climb at the beginning. What I did is I looked at lots and lots of examples (download EVOLVED's shader pack, for instance, although now that I look at that in retrospect, I do not advise it, because the complete absence of comments makes that scary), and tried to figure out what everything is doing and why.

You will need a solid understanding of higher level 3D math, such as vectors and matrices, and how to compute them together correctly. You also require a basic understanding of physics, such as how light behaves on different surfaces. Further, you will require some knowledge in parallel processing in order to understand more deeply how the GPU operates. It's definitely not the same as the CPU!

Good luck!

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Jun 2013 02:21
Quote: " It does seem like programming shaders is one of those things with a VERY steep learning curve"


Well worth the effort; you will not be disappointed for investing the time to learn.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 26th Jun 2013 03:00
Yeah, the math doesn't bother me. I'm a high school math and physics teacher and am considering going for a master's degree in math, too, so that part is relatively easy for me. It's getting the rules of the programming language right that is throwing me the most.

I find I learn best when I set goals for myself and work toward them. For example, my first programming goal is to learn how to create a shader for my Olympic weightlifting game that makes the lifter cast a shadow on the lifting platform. My next goal will be to make the lights in the rafters glow. I figure these should be relatively simple first-time projects for myself.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2013 12:11
Quote: "I find I learn best when I set goals for myself and work toward them. For example, my first programming goal is to learn how to create a shader for my Olympic weightlifting game that makes the lifter cast a shadow on the lifting platform. My next goal will be to make the lights in the rafters glow. I figure these should be relatively simple first-time projects for myself."


Believe it or not, those are actually not easy tasks.

I'd start with these (these require only single passes):
-Ambient lighting
-Specular lighting
-Bump mapping
-Normal mapping
-Parallax mapping

After that, I recommend looking at what the DBP community likes to call "fullscreen shaders". These are no different than the filters you can apply in GIMP or Photoshop (these require multiple passes):
-Bloom
-HDR
-Outline detection
-Motion blur
etc.

Then you can start moving on to more advanced stuff:
-Refraction
-Reflection
-Shadows
-Depth blur
-Water

If you google any of those along with the word "shader", you'll dinf loads of examples.

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Jun 2013 12:15 Edited at: 26th Jun 2013 12:24
Quote: " For example, my first programming goal is to learn how to create a shader for my Olympic weightlifting game that makes the lifter cast a shadow on the lifting platform."


Shadows are one of the most awkward things to get right in DBPro and I wouldn't normally recommend starting from there. However, in this instance, if your lifting platform is a flat horizontal surface wide enough to contain all the shadow then there is a simple solution provided by Bond1 using a simple planar shadow shader. I'll try to find the link and edit this post.

Welcome to the world of shaders!

Edit Bond1 introduces his shader here:

http://forum.thegamecreators.com/?m=forum_view&t=174395&b=24

I'm not sure where the shader itself is though. Post back if you get stuck as I might have a copy lurking somewhere.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Jun 2013 15:15
-Motion blur

I need motion blur. Does that work on the background, or the object?

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Jun 2013 15:27 Edited at: 26th Jun 2013 15:47
There various ways of achieving various forms of motion blur; some just blur moving objects, others create glow streaks along movement paths of fast moving objects, like the cars in Need For Speed.

Starting with the easiest that even a newbie can achieve, you draw the camera to an image and paste the rendered image semi transparently over the previous 5 or so frames. This doesn't require shaders and no it won't slow your engine down, you just use 3D planes or use advance2d to draw the images. Its a form of union skinning; only moving objects blur as they move. I used this ever faintly in my old Sports Fiction car video last year, although the video capture was choppy.

Moving up a scale, you have duplication method; duplication of vertices in the Vertex function and downsampling of the highlights in a screen camera. You supply the shader with the old positions of the object and it draws the old positions semi-transparenty. You can even use some of the heat haze techniques to play around with the pixels along the path of motion.

Lots of ways; I am sure there are shader examples on the net which achieve it in various ways.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2013 16:06
A more advanced way which can look a lot better, but may be a little slower: You can use the pixel shader to apply a convolution filter to the screen image.

http://lodev.org/cgtutor/filtering.html

The matrix can be calculated in the vertex shader by passing the camera's old and new positions/angles. From the link, this would be a 9x9 motion blur matrix for a 45° angle (should probably downsize it to 5x5 for a speed gain):



TheComet

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 26th Jun 2013 16:43 Edited at: 26th Jun 2013 16:44
The sort of blur that I want would be on the background like this...

http://onlyhdwallpapers.com/train/architecture-trains-rail-subway-tunnel-blur-desktop-hd-wallpaper-248374/

With none blurred foreground objects.

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 26th Jun 2013 16:51 Edited at: 26th Jun 2013 17:46
UPDATE : I was corrected in a post bellow, RenderMonkey DOES allow DirectX shaders to be experimented with. I was thinking of another 3D render engine and got the two names confused with the word Monkey in it. lol

This is the part of my post that is wrong :

As was previously mentioned.. Rendermonkey is a great way to learn shaders.. except one problem.. It's for OpenGL, not DirectX. OpenGL uses GLSL shader referencing.


DarkBasic Pro uses DirectX and DirectX uses HLSL shader referencing. The two languages are slightly different and thus one won't work on the other.

So if your going to use DarkBasic as your compiler and you want to add shaders, you need a HLSL shader. You can learn the tutorials on how HLSL works here :

http://www.riemers.net/eng/Tutorials/DirectX/Csharp/series3.php

Keep in mind, that link references to C# as its compiler language. But the HLSL shaders that are in the tutorial on that link will work in DarkBasic Pro. So all you would need to know is how to call shaders into DBP. Use this command...



DBP Help says "If the Texture Flag is set to zero, the effect will use the textures already mapped to the model, and a value of one will discard the current textures and load the textures specified in the FX file."

Also, just a side note, the file can be named whatever you want it to be. It doesn't have to have the FX file extension. You can name it shader.bodacious and it will load it that way just fine.



Hope this helps.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jun 2013 17:12 Edited at: 26th Jun 2013 17:14
Quote: "except one problem.. It's for OpenGL, not DirectX."


That's a load of crap.

RenderMonkey supports HLSL, GLSL, and GL ES.

Besides, DarkBASIC doesn't abide perfectly to HLSL either, it's some weird warped version of HLSL. Getting shaders to work in DBP sometimes requires a little bit more tweaking, and I've found that a few commands are missing, too.

[EDIT] @ Pincho - The convolution matrix I posted can do that.

TheComet.

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 26th Jun 2013 17:38 Edited at: 26th Jun 2013 17:41
Quote: "That's a load of crap.

RenderMonkey supports HLSL, GLSL, and GL ES."


Your absolutely right, my brain was thinking of MonkeyEngine at the time. http://jmonkeyengine.org/

Sorry for the confusion.

However, It's a shame RenderMonkey is no longer supported.

http://developer.amd.com/resources/archive/archived-tools/gpu-tools-archive/rendermonkey-toolsuite/


Quote: "Besides, DarkBASIC doesn't abide perfectly to HLSL either, it's some weird warped version of HLSL."


So far, I have had no issues. But that doesn't mean anything. There might be functions that DBP doesn't support that regular HLSL uses. That is very possible. I just haven't ran across that problem yet.
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Jun 2013 17:55
It will be interesting to see what results you all come up with.

JackDawson
14
Years of Service
User Offline
Joined: 12th Jul 2011
Location:
Posted: 26th Jun 2013 18:24 Edited at: 26th Jun 2013 18:27
If you want to play with a working water shader, try out my source code i slapped together here.

http://forum.thegamecreators.com/?m=forum_view&b=1&t=188775&p=2

Keep in mind, I didn't make the HLSL shader itself, I just got it working with my terrain demo. The code is a mess, as back when I made that I was just learning DarkBasic Pro. So its a hack job. But you can at least see how the water shader is working.

The File your going to be interested in is water.dba. It calls in the other files for that water shader.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Jun 2013 23:16 Edited at: 26th Jun 2013 23:35
I've often wondered what the point of motion blur is. Can someone enlighten me? I don't think I've ever seen it except in poor quality cinematography [Edit and cartoons of course ].
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Jun 2013 00:02 Edited at: 27th Jun 2013 00:05
Quote: "@ Pincho - The convolution matrix I posted can do that."


Just what I need thanks!


Quote: "I've often wondered what the point of motion blur is. Can someone enlighten me?"


You do see motion blur if you look out of a train window. The idea is to recreate what you could see in real life. But in some old movies it was done so badly that it looked wrong... Judge Dredd springs to mind... the motorcycle scene.

I just need it for a Greyhound Race effect that needs to match a music composition. The music sounds like the dogs have gone into a motion blur effect.

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 27th Jun 2013 01:01
I think what this forum really needs is a completely separate board dedicated solely to programming shaders. There is so much to learn about shaders, especially those like me who are just starting, and it seems like you have to dig long and hard through the boards to find information about shaders.
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 27th Jun 2013 01:06
Quote: "I should have added that your shader works perfectly once the semantics have been added. Good luck with this."

Indeed it did Thanks again. I didn't actually write the code in that shader -- well, not really -- I wrote it in Notepad by following step-by-step instructions on a tutorial site that I found. It eventually has more advanced shaders such as diffuse lighting and so on, so I'm using that to get myself acclimated to shaders.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Jun 2013 12:19 Edited at: 27th Jun 2013 16:37
Quote: "You do see motion blur if you look out of a train window."


If you see it at all (I've never actually noticed it) then it's caused by an aftereffect on the eye's retina, etc. So you should see it anyway just by looking at moving images on the screen.

As I said before, I don't see the point of artificially building it into your game - except as a gross exaggeration of a real life effect as in a cartoon.

Quote: "The idea is to recreate what you could see in real life."


Agreed. You need to think about the cause of the motion blur that you claim to see and why you think you need to build it into your game.

Edit The following, somewhat brief, article explains the issue rather clearly:

https://en.wikipedia.org/wiki/Motion_blur#Negative_effects_of_motion_blur

As explained there, "motion blur" is present anyway when the eye looks at a moving image so why build in more?

Edit2 Tried to fix link but it wouldn't work for some reason.

Edit3 Finally fixed the link. Must be having an off day.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Jun 2013 14:05 Edited at: 27th Jun 2013 14:06
Quote: "As explained there, "motion blur" is present anyway when the eye looks at a moving image so why build in more? "


The article says the opposite, that there is no motion blur in still images like video unless you add it, so the images look wrong. It says that some football matches use fast cameras so that the ball does not blur, but it looks unnatural. The eyes do not create their own motion blur on still images like computer games which are still images.

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Jun 2013 14:24 Edited at: 27th Jun 2013 14:25
There are useful applications for Motion Blur; but sadly it is often used poorly; a bit like lens flares or bloom being used poorly or overused.

Here are some uses that spring to mind;

A: Feedback showing that some kind of potion, special move or driving shift has been performed without sound or UI. In some games the character gets temporarily blinded or dazed and the screen is motion blurred (or onion skinned like I mentioned earlier)

B: Bullets are so small and they move too fast for the screen to pick up; so the motion blur helps highlight trajectories for aesthetics or tactical game-play.

C: Turbo: Light-speed travel in Star Trek; Nitrous turbo drive in Need For Speed; turbo in Street Fighter. Without such feedback,a casual player will find it difficult to comprehend that something is moving faster than is normal.

D: Stylized transitions from scene to scene; for example panning or zooming from one place to another place miles away very quickly.

E: Pawn movement. In some games like Civilization 5; the view gets very VERY busy; filled with details. When a pawn is moved automatically, the motion blur shows you the path taken for a few seconds then fades. Very useful for when the performance stutters while AI is being calculated.

Quote: "Some video game players claim that artificial motion blur causes headaches.[4] For some games, it is recommended to disable motion blur and use a high refresh rate screen and playing with a high fps count, that way it becomes more natural to pinpoint objects on the screen (useful when you have to react to them in small time windows). Some[who?] players argue that motion blur should come naturally from the eyes, and screens shouldn't need to simulate that effect."


True, that's where I say people in nice jobs with plenty of time and money to waste have no issue ranking up the motion blur so much just because they can. It looks good to them for a few hours couldn't care less how much it hurts the eyes; they're getting paid on Friday...

My personal policy is that if used for aesthetics and not function, the viewer should not be able to tell that motion blur was used; they should not be able to tell how anything was used to create any realistic effect period.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 27th Jun 2013 14:24
Battlefield 3 and planet side 2 have motion blur. It just makes the screen have a directional blurr when you quickly/rapidly look around. It's just eye candy to make things look nicer.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Jun 2013 14:53
Quote: "It's just eye candy to make things look nicer."


Indeed, this is the whole point. This, and what Chris said.

TheComet

Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Jun 2013 15:19 Edited at: 27th Jun 2013 15:20
Wow this is so slightly off topic, but have you seen the FPS Creater Reloaded latest use of shaders. A step up in the right direction.


That's what you can look forward to; anyone who is thinking about learning how to use shaders.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Jun 2013 16:34
Quote: "The article says the opposite"


So it does.

In fact one of the links in that article gives the reason why motion blur does need to be added (I read it more carefully this time ):

https://en.wikipedia.org/wiki/Saccadic_masking

The decay time for the blur effect in the human eye is shorter than the usual time interval between frames, i.e. 10ms compared to 30 ms, so you don't see blur in a typical PC game unless it's added.

Thanks for the corrections everyone (and apologies to TheComet ).
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Jun 2013 23:15
Huh, that's very interesting! Thanks for sharing

TheComet

PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 27th Jun 2013 23:43
Quote: "The article says the opposite, that there is no motion blur in still images like video unless you add it, so the images look wrong."


When George Lucas was producing Empire Strikes Back, the ATATs and such were done with stop-motion animation and never looked right because each frame was still, so he invented what he called "go-motion" in which the models were moved slightly during the exposure to create motion blur and made the frames look far more natural than had been achieved with stop motion up until then.
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 2nd Jul 2013 05:21
Hate to bother everyone with another noob shader question, but yeah, this whole learning curve thingy is steep...

I have been going through a tutorial page and the shader that they provided for learning how to do diffuse lighting isn't working properly. I see ambient lighting when I load the shader, but there is no diffuse lighting and all I see is a circle of uniform gray.

Here is the shader that was provided on the site (with the modification that Green Gandalf gave me a week ago).

CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 2nd Jul 2013 13:28
What specifically are you referring to when you say "diffuse lighting"? Do you mean the texture channel for diffuse?


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Jul 2013 17:05
It looks like the same problem as before - you need to give WorldInverseTranspose a value (I didn't spot it lower down the code before ). You should, at the same time, check that everything else declared is given a value either directly or via semantics. Same with any other language really - and it's often unwise to rely on default values being what you want.

I guess shader variables default to zero when not explicitly given values. (Not always true - but will suffice for now. )
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 2nd Jul 2013 18:58
Ah, you did it again, Green Gandalf! I think I see what is happening now. In the tutorial, it is assuming that the programmer will pass those variables from the main program. I see now that I need to declare all of them within the shader, now that you have taught me how.
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 2nd Jul 2013 21:13
I started playing around with the shader now that it's working and figured out how to create two distinct sources of diffuse light, each with separate intensity and color. I think this means I am now officially hooked on shaders.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Jul 2013 02:19
Quote: "I am now officially hooked on shaders."


CumQuaT
AGK Master
16
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 3rd Jul 2013 03:59
hehe glad it's all sorted out!

Oddly enough, I didn't know about the zero value thing, either. You learn something new every day! (Especially when Green Gandalf is around )


SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 9th Jul 2013 22:04
Hey
Sorry, this is basically my own, unrelated question in this thread! But since it's about something in this thread, it didn't seem like it was worth a new thread...
Just wondering, Chris Tate posted on page 1 some examples for how motion blur could be done... This is awkward, because I've been programming with DBP since 2008, and don't like to think of myself as new to it... But I'm confused about the easy (non-shader) method! He said 'paste the image over the past 5 or so frames'... I'm confused by that
I feel a bit stupid here, but how do you paste to any frame other than the current one?!
Thanks
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jul 2013 23:54
Yes, I wondered what he meant by that too. Let's hope he clarifies that for us.
PirateJohn
14
Years of Service
User Offline
Joined: 4th Aug 2011
Location: California
Posted: 10th Jul 2013 05:06
Okay, another noob question...

I'm now trying to get into texturing the model (I really need to find a better tutorial page) but the code isn't working. When I use the code I've attached, I get ambient lighting and specular lighting, but the diffuse lighting as well as the texture don't appear on screen. So, basically, I get a very dark object with one bright spot on it.

Mage
Valued Member
19
Years of Service
User Offline
Joined: 3rd Feb 2007
Location:
Posted: 10th Jul 2013 08:09 Edited at: 10th Jul 2013 08:11
Quote: "Just wondering, Chris Tate posted on page 1 some examples for how motion blur could be done... This is awkward, because I've been programming with DBP since 2008, and don't like to think of myself as new to it... But I'm confused about the easy (non-shader) method! He said 'paste the image over the past 5 or so frames'... I'm confused by that
I feel a bit stupid here, but how do you paste to any frame other than the current one?!"


Quote: "Yes, I wondered what he meant by that too. Let's hope he clarifies that for us."


When he mentioned it I assumed he meant using Get Image, Set Camera To Image or a similar technique. Because get image would pickup not just the current frame but also the blur effects from previous frames, you'd probably get more then a 5 frame blur as older frames would linger in the blending. Since we are talking about many frames quickly they'd still drown out in a small time.

With set camera to image you could strictly enforce that 5 frame limit (which wasn't an important rule). All your finished effects (except motion blur) and everything is drawn to a camera other then 0. Then that non-blurred finished screen is sent to an image. Then on camera 0 the newest frame is blended with the last 5 frames with the last 5 images.

Blending is done by having the newest frame drawn at 100% opacity first then laying each frame newest to oldest overtop with the transparency dropping with each layer so older frames become less significant gradually. This can be done linear by simply evenly dropping the percentage each layer. Or you might find better results using a sine curve to round out the drop in transparency.

But I'm not a mind reader, he could have been thinking anything.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Jul 2013 02:47
Quote: "But I'm not a mind reader, he could have been thinking anything."


Indeed.

Login to post a reply

Server time is: 2026-07-07 10:13:29
Your offset time is: 2026-07-07 10:13:29