Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

Ashnarott

Frischling

  • »Ashnarott« ist der Autor dieses Themas

Beiträge: 57

Beruf: Student Maschinenbau

  • Private Nachricht senden

1

03.12.2007, 22:39

Simpler Glow Effekt mit Vertex Shader

Hallo ich hab im Buch mir mal den simplen Vertex Shader für den Glow Effekt angeschaut. Ich habe leider von denen noch gar keine Ahnung und wollte fragen ob ich beim Effekt-code alles richtig gemacht habe. Im FX-Composer zeigt er nämlich eine Fehlermeldung an und wenn ich die Datei laden will kommt auch eine Fehlermeldung.

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
float4x4 WorldView;
float4x4 Projection;
float4 GlowColor = float4(0.5f, 0.2f, 0.2f, 1.0f);
float   GlowThickness = 0.15f;

struct SVertexShaderOutput
{
    float4 Position : POSITION;
    float2 Texture : TEXCOORD0;
    float4 Diffuse   : COLOR0;
}

SVertexShaderOutput VertexShaderProc(float4 InPosition : POSITION,
                    float3  InNormal : NORMAL,
                    float2  InTexture : TEXCOORD0,
                    float4  InDiffuse  :  COLOR0)
{
    SVertexShaderOutput Output = (SVertexShaderOutput)(0);

    float3 Pos = mul(InPosition + GlowThickness * InNormal, (float4x3)(WorldView));

    Output.Position = mul(float4(Pos, 1.0f), Projection);

    Output.Diffuse = GlowColor;

    return Output;
}

TECHNIQUE T1
{
    PASS P1
    {
    VertexShader = compile vs_1_1 VertexShaderProc();
    }
}

Black-Panther

Alter Hase

Beiträge: 1 443

Wohnort: Innsbruck

  • Private Nachricht senden

2

03.12.2007, 22:59

Ohne Fehlermeldung wirds ziemlich schwer dir zu helfen! ;)

Grober Fehler wär mir aber keiner aufgefallen.
stillalive studios
Drone Swarm (32.000 Dronen gleichzeitig steuern!)
facebook, twitter

Ashnarott

Frischling

  • »Ashnarott« ist der Autor dieses Themas

Beiträge: 57

Beruf: Student Maschinenbau

  • Private Nachricht senden

3

04.12.2007, 06:55

Also es kommt ja nur eine im FX-Composer und der schreibt"error X3000: syntax error: unexpectet token 'VertexShaderProc'". Und sonst kann er sie halt nur nicht laden. Vieleicht mach ich auch was in der Lade funktion falsch

C-/C++-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    if(FAILED(hResult = D3DXCreateEffectFromFile(g_pD3DDevice,
                                                 "effect2.fx",
                                                 NULL,
                                                 NULL,
                                                 0,
                                                 NULL,
                                                 &g_pEffect,
                                                 NULL)))
    {
        // Fehler! Womöglich ein Syntaxfehler in der Effektdatei!

        MessageBox(g_hWindow, "Der Effekt konnte nicht geladen werden!\nMöglicherweise ist er fehlerhaft.",
                   "Fehler", MB_OK | MB_ICONEXCLAMATION);
        TB_ERROR_DIRECTX("D3DXCreateEffectFromFile", hResult, TB_ERROR);
    }


Also ich habs so verstanden das man den Shader ganz normal wien effekt laden muss und wenn ich einen einfachen Effekt verwende funktionierts ja prächtig :) Hoffe mal das hilf jetzt meinen Fehler zu finden ;) Danke schomal

4

04.12.2007, 07:44

Du hast ein Semikolon vergessen:

C-/C++-Quelltext

1
2
3
4
5
6
struct SVertexShaderOutput
{
    float4 Position : POSITION;
    float2 Texture : TEXCOORD0;
    float4 Diffuse  : COLOR0;
}; // <--  HIER

Nico

Frischling

Beiträge: 82

Wohnort: Nürnberg

  • Private Nachricht senden

5

04.12.2007, 08:09

Kann man sich bei DirectX keine Fehlermeldung vom Shader-Compiler geben lassen? Bei OpenGL geht das... sollte doch bei DX auch möglich sein. Da gestaltet sich die Fehlersuche dann etwas einfacher.

edit:

Zitat


pDevice
[in] Pointer to the device that will create the effect. See IDirect3DDevice9.
pSrcFile
[in] Pointer to the filename. This parameter supports both Unicode and ANSI strings. See Remarks.
pDefines
[in] Optional NULL-terminated array of preprocessor macro definitions. See D3DXMACRO.
pInclude
[in] Optional interface pointer, ID3DXInclude, to use for handling #include directives. If this value is NULL, #includes will either be honored when compiling from a file or will cause an error when compiled from a resource or memory.
Flags
[in] If pSrcFile contains a text effect, flags can be a combination of D3DXSHADER Flags and D3DXFX flags; otherwise, pSrcFile contains a binary effect and the only flags honored are D3DXFX flags. The Direct3D 10 HLSL compiler is now the default. See DirectX 10 HLSL Compiler (Direct3D 10) for details.
pPool
[in] Pointer to a ID3DXEffectPool object to use for shared parameters. If this value is NULL, no parameters will be shared.
ppEffect
[out] Returns a pointer to a buffer containing the compiled effect. See ID3DXEffect.
ppCompilationErrors
[out] Returns a pointer to a buffer containing a listing of compile errors. See ID3DXBuffer.

Aus der C++-Doku^^.
Also: Den letzten Parameter auf keinen Fall nur ne "NULL" mitgeben, dann gibts auch ne ordenliche Fehlermeldung :). Tipp für die Zukunft :).
lg

6

04.12.2007, 08:43

So in etwa:

C-/C++-Quelltext

1
2
ID3DXBuffer* errors = 0;
D3DXCreateEffectFromFile( g_pD3DDevice, "effect2.fx", 0, 0, D3DXSHADER_DEBUG, 0, &g_pEffect, &errors );

Faule Socke

Community-Fossil

Beiträge: 1 915

Wohnort: Schreibtischstuhl

  • Private Nachricht senden

7

04.12.2007, 09:34

cool obwohl ich noch nicht eine einzige zeile shadercode geschrieben habe, ist mir auch sofort aufgefallen, das da was fehlt *von selbststolz erfüllt sei* :D :D :D

BlackSnake

Community-Fossil

Beiträge: 1 549

Beruf: Student

  • Private Nachricht senden

8

04.12.2007, 13:56

wir soind alle stolz auf dich, socke... ;)

Ashnarott

Frischling

  • »Ashnarott« ist der Autor dieses Themas

Beiträge: 57

Beruf: Student Maschinenbau

  • Private Nachricht senden

9

04.12.2007, 15:35

Omg ich idi^^...aber danke jetzt funzt es schon mal. Ich hätte noch eine Frage, die Sichtmatrix ist das die Kameramatrix? Und wenn nicht, wie kriegt man die Sichtmatrix? Danke schonmal für die Hilfe :)

TrommlBomml

Community-Fossil

Beiträge: 2 117

Wohnort: Berlin

Beruf: Software-Entwickler

  • Private Nachricht senden

10

04.12.2007, 16:42

wenn du die view-matrix meinst jo^^

Werbeanzeige