The Game Creators
The Game Creators Home Online Shop Click to Login
  Hot: Christmas CompetitionNovember NewsletterModel Pack 36DB Pro Pack 2009DGS BonanzaCharacter PackFPS Creator Bonanza;
The Game Creators
DBPro / Learning to write Shaders

Go to the first page of this board Return to the Forum Menu Post Message
1,671 Messages - Page   of 42   
Bookmark and Share Search the Forum Next 40

Author Message
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 18th Oct 2006 16:06     Edited: 29th Jul 2007 09:09     | link | toggle

USE THIS THREAD TO POST ANY QUESTIONS ABOUT SHADERS

---------------------
-------------------------

This thread was originally started at the beginning of the nVidia competition, when we learnt that it would be marked heavily on use of shaders, and everyone realised they didn't have a clue how to write or use them.

Over the course of the competition, many of the community took the plunge and came up with a fairly decent knowledge of how to write shaders for use in DBPro.

This thread, therefore is fairly invaluable to anyway wanting gorgeous graphics in their game, hence its new home, at the top of the DBPro board.

It is probably the best place to ask questions if you are trying to learn - currently there is a fairly good tradition that people who have been helped to learn have stuck around to help others, it would be awesome if that could continue.

Enjoy!

-------------------------
---------------------


UPDATE.
-----------------
Some helpful info from GG on where to find good docs:
***************************************************
Three that I've found useful are:

1. "Programming Vertex and Pixel Shaders" by Wolfgang Engel. [He has written several other books that I haven't seen and has a website with a few tutorials.]

2. "Shaders for Game Programmers and Artists" by Sebastien St-Laurent.

3. "Microsoft DirectX9 Programmable Graphics Pipeline" by Kris Gray. [As is usual with Microsoft this book was better at convincing me that there was a lot I didn't know than actually telling me something I wanted to know. But it did explain some things I hadn't appreciated before.]

All three books come with CD demos, etc, but I haven't seen the CD for book 3 (it's a library copy and the CD has sprouted legs).

I particularly like the first two books and their demos. But I find "RenderMonkey", which I think both books use, a nightmare to use. However, RenderMonkey has some nice FX demos and, if you have the patience, you can rewrite the FX files for use in DBP.

FX Composer is a free shader resource which you might find useful.

I've also found some useful, but limited, HLSL tutorials using Google.
***************************************************************

Original Post:

OK, so I guess a lot of people are going to be in a position like me, where they really need/want to learn to write shaders for this competition.

I know there's going to be a tutorial in the next newsletter, but I guess that's going to be more getting them to work with DBPro than how to actually write them.

So any advice from anyone as to what tutorials to read?
Absolute beginner we're talking here.

I've got Render Monkey and I know C++ (the shader language is basically C isn't it?)

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Image All

User


Joined: Fri Dec 30th 2005
Location: I can feel my hair growing
Posted: 18th Oct 2006 19:05           | link | toggle

I think shaders are made in Ye Olde Assembley >.> of which I know nothing about, thus I can't realy help much

Back to top
Find user on ICQ
Report this message as abusive
sett

User


Joined: Sun Sep 19th 2004
Location: somewhere in my mind...
Posted: 18th Oct 2006 19:49           | link | toggle

They can be written in C++, I think. Or you can use RenderMonkey or the NVIDIA Shader composer.


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Back to top
Report this message as abusive
Lukas W

User


Joined: Fri Sep 5th 2003
Location: Norway
Posted: 19th Oct 2006 00:57           | link | toggle

you can try this tutorial: http://vvvv.org/tiki-index.php?page=pixelshader_for_newbies
i may have a closer look at shader programming too. though at the moment Evolveds shaders and the DBPro Shadow shader is good enough for me.

Back to top
Send AIM user a message
Report this message as abusive
Raven

User


Joined: Wed Mar 23rd 2005
Location: Hertfordshire, England
Posted: 19th Oct 2006 01:32           | link | toggle

I'll try to explain them here a bit as tbh there aren't many decent online tutorials.

Alright we.. firstly I'd suggest using FX Composer for Shaders.
It fully supports any DirectX Shader Card, Shader Model 1.x / 2.x / 3.0 as well as supporting Software 1.1.
When you add to that functionality the ability to load, link and/or use up to 255 Shaders at any given time with a visual thumbnail of what they do and an option of adding them either as a Screen or Object Effect, then you have a fairly powerful tool.
You can also preview real-time, recompile quickly, change variables on-the-fly, view current samplers loaded / output.
Along with the main C-Style Coding Window.

All of which is customisable to your own preference. So you have a fairly powerful creation utility at your disposal. However another good point is that it provided help information on DXSAS1.0 Compliancy, something DBP now has meaning shaders theoretically can be used without any editing as well as exporting to be compatible with Ashli (so you can load/use in Maya/Max/XSI for model development means)

On the whole it makes shader development a damn sight easier, especially from a coding point of view.

Now I think I'll cover what DBP doesn't support.
Inline Functions : Useful technique used for creating samplers each time the function is called. While there is a way to do this, it is only supported by outputting the Shader as ASM, but DBP HLSL doesn't support this yet. To output ASM from FXComposer then click on Shader Perf and select your card.. Your card MUST support shaders to use Shader Perf. So those of you using it in Software 1.1 mode (like I am right now you can't access it).

Scripting : This can be useful for having shaders run slightly differently based on what is going on as well as controlling the function order better. Can increase performance and functionality under the right circumstances, but DBP doesn't support this and don't see why it ever will tbh as for most games it's pointless.

Shader 3 : Technically yes this is supported, but only the most basic implimentations that can revert back to 2.0.. so don't even bother using it. Again this is a feature that can be used with the ASM shaders, but the complexity of sorting out SM3 in ASM is honestly not worth the benifits over 2.0 HLSL. Only use that as a last resort.

There's a number of other things to look out for when making shaders for DBP, but I don't have a lot of time right now to explain them all. Mostly it's semantic stuff.

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Back to top
also available from http://www.liandri.eu
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 19th Oct 2006 12:31           | link | toggle

Cheers everyone.

Raven's sold me FX Composer, I'll download it.

It sounds basically the same as Render Monkey but maybe a bit better.

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 19th Oct 2006 14:13           | link | toggle

@Chris K

Yes, I agree with virtually everything Raven said, FX Composer is very good - definitely worth the wait while it downloads from NVIDIA. Also, it's MUCH easier to use than RenderMonkey (except that you have to write all the code yourself, but on the other hand, the shaders you will want here will be quite short really). Also, the FX files exported by RenderMonkey usually need editing before they work in DBP - but RenderMonkey does have some nice examples which you can adapt.

If you have questions, post them here and someone will probably help you. I will certainly try to help if I can. I think you get points for discussing your work here - so keep the questions coming.
Back to top
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 19th Oct 2006 15:04     Edited: 19th Oct 2006 15:05     | link | toggle

Awesome.

There are some RenderMonkey example that I'm determined, eventually, to get into DBPro, but I'll be ecstatic to get anything that I've written working.

-------

I know what you mean about the wait. 11kb/s? What is this 2001?

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
sett

User


Joined: Sun Sep 19th 2004
Location: somewhere in my mind...
Posted: 19th Oct 2006 15:59           | link | toggle

does the sample shader that are already here are 100% royalitie free?


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 19th Oct 2006 16:59           | link | toggle

Those that I've posted on the main DBP board and the WIP/Ultimate Shader Pack certainly are - and I think most, if not all, in the Ultimate Shader Pack are too (but you'll have to check).
Back to top
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 20th Oct 2006 13:33           | link | toggle

Does a shader loaded into DBPro do anything for you?

For example, would it automatically set view_projection_matrix or whatever, to the right value, or do you essentially set all the shader's variables yourself?

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 20th Oct 2006 15:54           | link | toggle

Quote: "For example, would it automatically set view_projection_matrix or whatever, to the right value, or do you essentially set all the shader's variables yourself?"

DBP passes various variables to the shader such as the worldviewprojection matrix and cameraposition as in the following snippet from one of my bump mapping shaders (see attached file for the complete code):

+ Code Snippet
matrix wvp : WorldViewProjection;
matrix mworld : World;
matrix winv: WorldInverse;
float3 eyePos : CameraPosition;


I'm not sure what the complete list of such variables is. That's the sort of information that is hard to find.

One thing to note is that shaders produced in RenderMonkey often refer to the viewprojection matrix rather than the worldviewprojection matrix. You usually need the latter for use in DBP (and FX composer). There will be some other related changes as well.

The following variables, taken from the same shader, are variables you would usually want to vary in your DBP program:

+ Code Snippet
float4 lightDir   = {-1.0f, 0.0f, 0.0f, 1.0f};
float4 ambiColor  = {0.2f, 0.2f, 0.2f, 1.0f};
float4 lightColor = {1.0f, 1.0f, 1.0f, 1.0f};
float specPower = 0.31;
float specLevel = 0.5;


The values given are just default values used by the shader.

To change those values in DBP you would use commands such as set effect constant vector and set effect constant float.

Hope this helps.
Back to top
Download: ggbump01e.fx Size: 3167 bytesReport this message as abusive
dab

User


Joined: Wed Sep 22nd 2004
Location: You Temp Folder!
Posted: 20th Oct 2006 19:56     Edited: 20th Oct 2006 19:59     | link | toggle

Where are the shaders located?
Edit: The Download That is. I can't seem to find it in any of the Ultimate Shader Threads.

Edit2: Found it.
http://forum.thegamecreators.com/?m=forum_view&t=79849&b=8 (Thread)
http://cordierfr.free.fr/UltimateShaderPack1.0finale.zip (Shaders)

Uhh. I'm too lazy to fill this in right now. When I get the nvidia game further into working, I'll add a post to it.
Back to top
dab-Media
Report this message as abusive
sett

User


Joined: Sun Sep 19th 2004
Location: somewhere in my mind...
Posted: 20th Oct 2006 20:41           | link | toggle

How can I have the fire sahder from the fx composer shader gallery. They say that the sample come with fx composer but there is no sample at all.


Windows XP,pentium IV, 3.0 MGZ, 1024 mb memory, 256 mb ATI Radeon PCIE X700 Pro 'sett squadron back on the assault'
Back to top
Report this message as abusive
Michael S

User


Joined: Sun Apr 2nd 2006
Location: Why do you ask?
Posted: 20th Oct 2006 20:52           | link | toggle

What are shaders?

Back to top
NinjaSoft Games
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 21st Oct 2006 04:57     Edited: 21st Oct 2006 05:11     | link | toggle

Basically a tiny little program that runs on an individual pixel (or vertex), to produce an effect.

They are written in a language specifically designed for GPU hardware, so they are incredibly fast at doing things that would take a long time on a CPU.

-----------

Thanks GG, helped a lot.

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 21st Oct 2006 08:43     Edited: 21st Oct 2006 08:47     | link | toggle

In the Fresnel Water shader, what does the clipping do (set camera clip)? It appears to do nothing, is it just an optimisation?

-------

Oh wait I get it now.
It's so refraction camera only sees stuff below the water, and the reflection only sees stuff above the water.

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Raven

User


Joined: Wed Mar 23rd 2005
Location: Hertfordshire, England
Posted: 21st Oct 2006 09:00           | link | toggle

Probably just an attempt at optimisation, as shaders work based on the screen-size. The smaller, the better they perform.

I mean you're no doubt going to expect more 3D work at 1280x720 than you would at 640x480, however let's say you have a normal mapped plane in the center of the screen that takes up 100x100px

With a 3D Texture, all it would do would be to stretch it across the surface meaning you end up with a blurred 1:1 at the higher resolution. A shader however will work in the additional pixel space making the normal mapping much better, and you'd end up with a 1:1 at 640x480 and 2:1.3 at 1280x720
Hopefully that makes sense.

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Back to top
also available from http://www.liandri.eu
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 21st Oct 2006 09:36     Edited: 21st Oct 2006 09:37     | link | toggle

?

Umm, what?

I already figured it out. ^^^

I had nothing to do with what you said...
It just sets the draw distance, essentially, of the cameras.

-----------------

Is 1280x720 720p widescreen? ie. 360 standard?

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Gamefreak

User


Joined: Sun Jun 20th 2004
Location: Cyberspace
Posted: 21st Oct 2006 10:16           | link | toggle

Is there anyway to update my shader version, like to 2.0? My graphics card doesn't support a lot of the shaders in the pack.
Back to top
Report this message as abusive
Google Ad
Back to top
 
MadrMan

User


Joined: Sat Dec 17th 2005
Location: 0x5AB63C
Posted: 21st Oct 2006 10:19           | link | toggle

Nope there isn't.. its hardware so you'll have to buy a new graphic card or just stick to lower versions


Back to top
Report this message as abusive
Raven

User


Joined: Wed Mar 23rd 2005
Location: Hertfordshire, England
Posted: 21st Oct 2006 10:45           | link | toggle

Quote: "I had nothing to do with what you said...
It just sets the draw distance, essentially, of the cameras."

:shrugs: I was taking a guess, as I didn't have the USP to check.
Do now, and the Fresnel Shader looks like the NVIDIA ASM one converted to HLSL. Seems a very silly way of doing it as performance is being lost by letting DBP do aspects that should be internal to shaders. Still does the job I suppose.

Quote: "Is 1280x720 720p widescreen? ie. 360 standard?"

Something like that, yeah. It's a resolution that's been around before HD though

What I ment above is that the rendered pixels for the texture, on the first example it's 1:1 meaning 100x100px output, then it's stretched over the surface. For the shader example 640x480 is the original size so again it's 100x100px, yet 1280x720 is larger so the shader rather than doing it's 1:1 does a 2:1.3 (in relation to the screen ratio) so the texture ends up being 200x130px rather than stretching. So it's doing alot more work with the fill-rate but also on the gpu itself.

hense, smaller screen = higher performance.
This is also true when considering a shader like HDR or Bloom. Generally a way around it is to use a shader quad (shader created quad that sets the screen sampler size output) that way no matter the resolution the shader doesn't slow down... on the negative side no matter the resolution the shader output will always be the same, which can mean HDR might end up being a much lower quality aspect than say Normal Mapping.

Also a better solution for the Fresnel Water, or any Reflect/Refraction is to use the Shader itself to determine the clipping surface using an emissive level, which will allow anything above the water to be classed as something different to below. another (and tbh easier method) is to use a cubemap (or even single camera dp reflect vector from eye) passed by dbp for the reflection and use the scene itself for refraction.

Either method will provide much quicker and more impressive results. ^_^

Intel Pentium-D 2.8GHz, 512MB DDR2 433, Ati Radeon X1600 Pro 256MB PCI-E, Windows Vista RC1 / XP Professional SP2
Back to top
also available from http://www.liandri.eu
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 21st Oct 2006 14:41           | link | toggle

@sett (and anyone else interested)
Quote: "How can I have the fire sahder from the fx composer shader gallery. They say that the sample come with fx composer but there is no sample at all."

Here's a fire effect shader plus demo DBP program in a zip file you might like to try. You need a ps2 capable GFX card.

When you run the program, just press "2" to get the fire effect.

Let me know if you have questions or problems with this.
Back to top
Download: gg fire effect v1.zip Size: 123808 bytesReport this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 21st Oct 2006 14:50           | link | toggle

Has anyone managed to get other shaders working with the Fresnel water?

I think it takes complete control of what goes into the backbuffer, basically.

I can't get HDR to work with it, and I think it's because of this.

The 'post' effects like HDR need to work on the image once it's had the water effects put in.

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
headcrab 53

User


Joined: Thu Jul 14th 2005
Location: Cyberspace
Posted: 21st Oct 2006 15:11     Edited: 3rd Dec 2006 15:21     | link | toggle

What's the Fresnel water?


Back to top
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 21st Oct 2006 15:30     Edited: 21st Oct 2006 16:03     | link | toggle

Ummm, it's the Fresnel Water shader.

It's in the shader pack, called, wait for it, Fresnel Water.

---------------

I managed to get bloom working with the water.
It doesn't work on the actual water, which I kind of expected, but it still looks good on the rest of the enviroment

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Turoid

User


Joined: Sat Nov 1st 2003
Location: The Netherlands
Posted: 26th Oct 2006 03:18           | link | toggle

Hi guys,

I was playing around with the shader pack to see if I could manage working with shaders for the nvidia comp.
Now here, I made a plain and moved with the camera around it. As you can see in the far right corner it seems that it just dissapears when the camera comes close to it, but not in the other corners? I hope this is fixable actually.. I guess there's nothing wrong with the shader.

Click the download butten for the video.

Thanks

Back to top
Download: shader_problem.wmv Size: 3411442 bytesReport this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 26th Oct 2006 03:35           | link | toggle

Had a quick look. I see what you mean. Will try to reproduce the problem myself (shouldn't take long). I suspect it's an object culling issue - but I'll check.

P.S. Thanks for posting here. It would be great if everyone else with competition related shader queries did that. Then everyone benefits.
Back to top
Report this message as abusive
Tinkergirl

User


Joined: Tue Jul 1st 2003
Location: United Kingdom
Posted: 26th Oct 2006 03:43           | link | toggle

Did you make the plain in a modelling package, or is it a DB standard plain? Just, if it's a modelling package one, then I'd suspect that your pivot point is off centre, and DB only renders it when the centre point is close enough to the screen.

If it's a DB plain, then I'm afraid I don't know.

Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 26th Oct 2006 03:53           | link | toggle

Sorry, couldn't reproduce your problem. The following code worked fine for me:

+ Code Snippet
set display mode 800,600,32
sync on: sync rate 0: sync
autocam off
position camera 0,30,-200
point camera 0,0,0

global cx#
global cy#

make object plain 1, 1000, 1000
position object 1, 0, 0, 0
xrotate object 1,90

load effect "FX/OffsetMapping.fx",1,1
set object effect 1,1

repeat
  text 20, 20, " fps = "+str$(screen fps())
  positionCamera()
  sync
until spacekey()

end

function positionCamera()
  control camera using arrowkeys 0,10,0
  cx#=cx#+mousemovey():cy#=cy#+mousemovex()
  rotate camera cx#,cy#,0
endfunction


I changed the shader slightly so it explicitly declares the textures - shouldn't be relevant to your problem though:

+ Code Snippet
   texture BaseTX 
    <
	string ResourceName="../Media/rockwall.tga";
    >;	
   sampler2D Base = sampler_state 
    {
 	texture = <BaseTX>;
    };
   texture HeightTX
    <
	string ResourceName="../Media/rockwall_height.tga";
    >;	
   sampler2D Height = sampler_state 
    {
 	texture = <HeightTX>;
    };
Back to top
Report this message as abusive
Turoid

User


Joined: Sat Nov 1st 2003
Location: The Netherlands
Posted: 26th Oct 2006 04:47     Edited: 26th Oct 2006 04:48     | link | toggle

I used the inbuilt DB plain primitive, but I rotated it and fixed it's pivot.

[EDIT]
I tried making a new project with the same code and it seems that it works fine therE? ?? :S

Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 26th Oct 2006 07:16           | link | toggle

Here's a simple reflection shader plus demo program people might like to play with. The cube map was made from images taken with cameras in another DBP application.

You can move around using the up/down keys and mouse to change direction.
Back to top
Download: gg reflection demo.zip Size: 777466 bytesReport this message as abusive
Cave Man

User


Joined: Tue Aug 22nd 2006
Location: North Carolina, US
Posted: 27th Oct 2006 17:06           | link | toggle

Thats a nice shader.
I've got a question. What does the mul function do?

Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 27th Oct 2006 19:54           | link | toggle

The mul function is used to multiply a vector by a matrix - often used in shaders to convert from one coordinate system to another. For example, position coordinates of a vertex are input to the vertex shader in object or model coordinates (the same ones you would see in a mesh in DBP. However, other things like camera position are passed in "world" coordinates, and to show things on the screen you need "view" coordinates (i.e. relative to the camera) and finally a "projection" to the screen coordinates. Hence shaders will often refer to 4x4 matrices such as WorldViewProjection which is a combined matrix giving the transformation of object coordinates to the screen, i.e. object -> world -> view -> screen projection.

Hence the following code snippet from my reflection shader is transforming input object coordinates into output screen coordinates. In the shader I have given the matrix WorldViewProjection the shorter name wvp for convenience.

+ Code Snippet
Out.Pos = mul(In.Pos, wvp);


Hope this explains a bit.
Back to top
Report this message as abusive
dab

User


Joined: Wed Sep 22nd 2004
Location: You Temp Folder!
Posted: 28th Oct 2006 04:24           | link | toggle

@Green Gandalf
Your reflection shader doesn't do objects in the scene. Only the outside, cube.

Take heed, never take advantage of the things you need, never let your self be overcome by greed. Walk a strigh line, pick up your speed and try. Everyone deserves a piece of the pie By: Shaggy
Back to top
dab-Media
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 28th Oct 2006 04:25           | link | toggle

Yeah that's for speed. Not everyone has a computer fast enough for real time reflections, these are prerendered.

It looks very good for how cheap it is.

-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 28th Oct 2006 06:26     Edited: 28th Oct 2006 07:53     | link | toggle

Quote: "Your reflection shader doesn't do objects in the scene. Only the outside, cube."

Yes, as Chris K says, that was done for speed. Real-time reflection rendering of the whole scene using set camera to image, etc, can slow things down enormously. Of course, you have to stop somewhere anyway - in a real-world version of my shader you would want a potentially unlimited sequence of reflections of one object in another. But how would you get that?

To get visually interesting effects and acceptable game speed you need to make a few compromises or approximations. I think several of the shaders in the Ultimate Shader Pack could do with reworking for speed with that in mind.

Quote: "Thats a nice shader."

Quote: "It looks very good for how cheap it is."

Thanks, guys. I'll keep posting simple shaders like that in case someone wants to use them.

[Edited typo.]
Back to top
Report this message as abusive
Cave Man

User


Joined: Tue Aug 22nd 2006
Location: North Carolina, US
Posted: 28th Oct 2006 22:12           | link | toggle

Thanks Green Gandalf. Can you make a simple shader that just turns all the pixels one color so i can learn? Thanks.

Back to top
Report this message as abusive
Chris K

User


Joined: Tue Oct 7th 2003
Location: Lake Hylia
Posted: 29th Oct 2006 05:02     Edited: 29th Oct 2006 05:03     | link | toggle

Here you go Cave Man:

Shader (save as MyFirstShader.fx):

+ Code Snippet
float4 color = { 1.00, 0.5, 0.00, 1.00 };

float4 MyFirstPixelShader() : COLOR
{

   return ( color );
}

technique MyFirstTechnique
{
   pass MyFirstPass
   {
      PixelShader = compile ps_1_1 MyFirstPixelShader();
   }
}


DBPro code:

+ Code Snippet
make object cube 1, 3

load effect "MyFirstShader.fx", 1, 0
set object effect 1, 1

set camera range 0.001, 100

color backdrop rgb( 255, 255, 255 )

sync rate 60
sync on
do

rotate object 1, object angle x( 1 ) + 1, object angle y( 1 ) + 1, object angle z( 1 ) + 1

position camera 5, 5, -5
point camera 0, 0, 0

sync
loop


-= Out here in the fields, I fight for my meals =-
Back to top
Report this message as abusive
Green Gandalf

Valued Member


Joined: Mon Jan 3rd 2005
Location: Cornwall UK
Posted: 29th Oct 2006 06:23     Edited: 1st Nov 2006 12:48     | link | toggle

Quote: "Can you make a simple shader that just turns all the pixels one color so i can learn? Thanks."

Try the attached.

I'm going to add to this in response to questions on this thread - time permitting of course.

Thanks for the nudge - I've been meaning to do this for a while.

[Edit: someone beat me to it while I was tinkering with the code! Serves me right for being too fussy!]

[2nd Edit: Changed the name of the zip folder so it doesn't refer to "Tutorials". That will come later when I've added explanations and more examples. There's only one shader in there at the moment. More will follow.]
Back to top
Download: s Shaders.zip Size: 5059 bytesReport this message as abusive

Go to the first page of this board Return to the Forum Menu Post Message
1,671 Messages - Page   of 42   
Search the Forum Next 40

This is a multi-page thread older than 30 days.
Go to the last page to check if you can reply to it.

Forum Search

Enter a word or phrase to search our Forum for:

Thread Subject Search
Search Phrase:
Search Scope: Entire forum
Just this board
 
Google Forum Search
Search Phrase:
 
Apollo v2.02


Game Creator Store
Privacy Policy AUP Top of Page