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.

Dark GDK / Shaders Causing Headaches

Author
Message
Hicksyfern
15
Years of Service
User Offline
Joined: 10th Jul 2009
Location:
Posted: 10th Jul 2009 17:17
Hi,

I've looked around the forums for how to sort this and it's driving me bananas.

I'm trying to learn how to use shaders with very little success. I have created a shader with the following code, to just draw me a red object when I load the shader:


Then I'm doing a simple:

dbMakeObjectSphere(1, 20);
dbLoadEffect("simple.fx", 1, 0);
dbSetObjectEffect(1, 1);

and my sphere disappears.

Is there anything else I need to set up to make my shaders work? I've tried downloading the "test compatability" shader by Green Gandalf and the same - my obhect simply doesn't draw.

What can I do to fix this?


Cheers,

Tom
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 11th Jul 2009 11:14
Are you using shader debugging?
Go to All Programs>DirectX SDK>DirectX Utilities>DirectX Control Panel
then check "enable shader debugging"
I don't know much about how shaders have to be set up for GDK, but you should replace this line:
colour = float4(1.0, 0.0, 0.0, 1.0);
with this
colour.Col = float4(1.0, 0.0, 0.0, 1.0);
And you've put
PS_INPUT ps(VS_OUT IN): COLOR
but the semantic is handled by the struct, so you just need
PS_INPUT ps(VS_OUT IN)

Actually, the whole struct is unnecessary because the only thing a pixel shader can output is one float4, so you just put:



p.s. you spelt colour with a u I always do that, I bet it will annoy 'mericans when i get into professional programming.

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 11th Jul 2009 12:18
Apart from jezza's suggestions, I think it is mandatory to compile in shader model 2.0 (as minimum). Try to change this:



To this:

jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 11th Jul 2009 13:54
Noitced your declaration of mvp. When using 'matrix' you have to put datatype and size, like this:
matrix <float, 4, 4> mvp : WorldViewProjection;
so it would be better just to use
float4x4 mvp : WorldViewProjection;

KirDael
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location:
Posted: 27th Jul 2009 20:27
your shader contains errors... wait i fix them ;P´

There are many things you don't need

KirDael
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location:
Posted: 27th Jul 2009 20:29
Sorry !!!! this one has no errors xD

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 27th Jul 2009 20:34
Morcilla already pointed out the major issue with the shader, and other than his 'colour = float4(1.0, 0.0, 0.0, 1.0);' (colour is a struct) his code looks fine. Yours may be shorter but it doesn't really make much sense when reading it, why use the PS_INPUT as the VS input? Plus you still didn't fix the pixel shader model issue.

KirDael
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location:
Posted: 9th Aug 2009 20:33
i dont understand you
Amnzero
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 9th Aug 2009 22:24
Join the club KirDael...

if(enemy == Amnzero) runAway();
Amnzero->WebSite = L"http://neovance.com/";
KirDael
15
Years of Service
User Offline
Joined: 22nd Jan 2009
Location:
Posted: 10th Aug 2009 11:56


well, my shader is working... but there could also be some mistakes because i wrote it down quickly...

Login to post a reply

Server time is: 2024-11-19 02:49:23
Your offset time is: 2024-11-19 02:49:23