• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Fredericvo

Unable to compile shader

8 posts in this topic

OK so I'm trying to move away from the FFP and step into the world of shaders and the first thing I get is an error LOL.
I'm trying to get [url="http://www.two-kings.de"]www.two-kings.de[/url] 's tutorial #18 to work but the pixel shader doesn't seem to compile. The executable they delivered worked on my computer but if I compile myself and run the program then the pixel shader fails)

I'm trying to isolate the problem so I made the following little C program

[CODE]#include <d3dx9.h>
#include <stdio.h>
#include <D3DX9Shader.h>

#pragma comment (lib, "d3dx9.lib")

LPDIRECT3DPIXELSHADER9 pixelShader = NULL;
LPD3DXBUFFER code = NULL;

int main() {

HRESULT result;
result = D3DXCompileShaderFromFile( "pixel.psh", //filepath
NULL, //macro's
NULL, //includes
"ps_main", //main function
"ps_1_1", //shader profile
0, //flags
&code, //compiled operations
NULL, //errors
NULL); //constants
if(FAILED(result))
printf("failed: %p %d %d\n",result,result,D3DERR_INVALIDCALL);
printf("failed: %p %d %d\n",result,result,D3DXERR_INVALIDDATA);
printf("failed: %p %d %d\n",result,result,E_OUTOFMEMORY);
Return 0;

}[/CODE]

Here is the supposed pixel shader

[CODE]// Pixel shader input structure
struct PS_INPUT
{
float4 Position : POSITION;
float2 Texture : TEXCOORD0;
};


// Pixel shader output structure
struct PS_OUTPUT
{
float4 Color : COLOR0;
};


// Global variables
sampler2D Tex0;


// Name: Simple Pixel Shader
// Type: Pixel shader
// Desc: Fetch texture and blend with constant color
//
PS_OUTPUT ps_main( in PS_INPUT In )
{
PS_OUTPUT Out; //create an output pixel

Out.Color = tex2D(Tex0, In.Texture); //do a texture lookup
Out.Color *= float4(0.9f, 0.8f, 0.4, 1); //do a simple effect

return Out; //return output pixel
}[/CODE]

And sure enough it fails but with none of the standard error values sch as [b]D3DXERR_INVALIDDATA or something like that.[/b]

[b]The vertex shader compiles fine.[/b]
0

Share this post


Link to post
Share on other sites
The compilation errors are returned to you in the ppErrorMsgs parameter. It will be in an ID3DXBuffer object, so you just need to call GetBufferPointer and cast the pointer to char* to read it as a string.

[code]
HRESULT result;
ID3DXBuffer* errors = NULL;
result = D3DXCompileShaderFromFile( "pixel.psh", //filepath
NULL, //macro's
NULL, //includes
"ps_main", //main function
"ps_1_1", //shader profile
0, //flags
&code, //compiled operations
&errors, //errors
NULL); //constants
if(FAILED(result)) {
const char* errstring = "";
if(errors != NULL)
errstring = reinterpret_cast<const char*>(errors->GetBufferPointer());
printf("failed: %s", errstring);
}
[/code] Edited by MJP
0

Share this post


Link to post
Share on other sites
Try compiling it with [url="http://msdn.microsoft.com/en-us/library/windows/desktop/bb509709(v=vs.85).aspx"]fxc.exe[/url], it should be in your <Microsoft DirectX SDK dir>/Utilities/bin/x86 directory.

With my version of fxc, I get "ps_1_x is no longer supported" (the vertex shader compiles with vs_1_1), so try using "ps_2_0" Edited by turch
0

Share this post


Link to post
Share on other sites
Yeah ps_1_1 is only supported with the legacy compiler, which requires the D3DXSHADER_USE_LEGACY_D3DX9_31_DLL flag.
0

Share this post


Link to post
Share on other sites
Thanks guys it worked. I had to either compile as ps 2.0 or use the following flag D3DXSHADER_USE_LEGACY_D3DX9_31_DLL

This being said I'm very surprised that it runs on my computer because I have no graphics adapter and use a built-in S3 Unichrome Pro IGP. (about the lamest video chip you can have for 3D)
I understand that vertex shaders can be emulated in software but I thought pixel shaders were ALWAYS hardware nowadays.
I haven't created a REF device but a D3DDEVTYPE_HAL. Edited by Fredericvo
0

Share this post


Link to post
Share on other sites
[quote name='Fredericvo' timestamp='1339861611' post='4949812']
Thanks guys it worked. I had to either compile as ps 2.0 or use the following flag D3DXSHADER_USE_LEGACY_D3DX9_31_DLL

This being said I'm very surprised that it runs on my computer because I have no graphics adapter and use a built-in S3 Unichrome Pro IGP. (about the lamest video chip you can have for 3D)
I understand that vertex shaders can be emulated in software but I thought pixel shaders were ALWAYS hardware nowadays.
I haven't created a REF device but a D3DDEVTYPE_HAL.
[/quote]

My bad I realise that the program runs (rather than crashes) but the pixel shader has no effect. Only if I DO use a REF device does it really work (painfully slow though as expected) so my S3 card is as bad as I thought LOL.
0

Share this post


Link to post
Share on other sites
Ancient chipsets are a huge pain to work with. This is 2012, I think a hardware [s]overhaul[/s] [s]upgrade[/s] renovation is called for [img]http://public.gamedev.net//public/style_emoticons/default/unsure.png[/img]

[quote]I understand that vertex shaders can be emulated in software but I thought pixel shaders were ALWAYS hardware nowadays.[/quote]
The REF device emulates everything, I believe - it simply ignores whatever graphics hardware you have. It basically behaves as if you had a fully featured, correctly working graphics card (minus the speed). The "software" device (i.e. HAL device with software assistance) however only emulates rasterization and vertex shading. As it should, anyway, I mean if the CPU starts texturing pixels you may as well plug the DVI cable in it and call it a day. Edited by Bacterius
0

Share this post


Link to post
Share on other sites
Talking about HW overhaul I'm on a budget.
Since I still have a lot to learn I believe that even an older card with vs/ps model 3.0 or so might suffice and if I were to market a game I'd want a larger audience anyway and I don't think I could wow hardcore gamers who want the greatest and the latest before long. What AGP8x card would be good? I have an AMD Sempron 3200+ on a k8m400 mobo. Or is this system really no longer worth upgrading? Maybe an i3 is the least I should consider?
0

Share this post


Link to post
Share on other sites
[quote]Or is this system really no longer worth upgrading?[/quote]
That would be my opinion. It has fallen too far behind, "upgrading" would basically mean replacing:
- the processor
- the graphics card
- the motherboard to go with the new processor and possibly graphics card (often overlooked)
- the power supply unit as your new hardware may require more power and possibly more cables
- any accessories no longer compatible with the new motherboard
In short, everything.

It is true that you don't need the greatest and latest to make games, however working on obsolete hardware is something I simply cannot recommend to anyone. It's not so much the performance itself, which is probably fine, but it's the compatibility and relevance to modern techniques that's the issue here. It's annoying, painful, and ultimately a waste of time as you will not have access to the more recent API's, and some graphics algorithms may require specific manipulations impossible to achieve on your side without hacks (think vertex shader texture lookup, depth buffer manipulation, etc...)

A card like the GeForce 210 is dirt cheap nowadays and while it's not exactly mainstream anymore, it is plenty fast enough for comfortable game development and actually has shader model 4 (DX10), which means you would be able to use most if not all state-of-the-art graphics techniques, for instance. Of course, if you don't have a PCI-E interface on your k8m400, you'll need an AGP graphics card and those have started to become collector material, if you get my drift.

Let's not get off topic, though. A Lounge topic would be more appropriate to discuss hardware upgrade considerations.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0