PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : HLSL-Gerüst


aths
2004-06-09, 12:45:07
Ich würde gerne mit dem fxc-Compiler herumspielen um herauszukriegen, für welche Targets SINCOS in Einzelbefehle zerlegt wird, und wann er SINCOS als Instruktion belässt. Wo finde ich beispielhaften HLSL-Code, den man entsprechend abwandeln könnte?

pajofego
2004-06-09, 14:23:28
Also ich arbeite die ganze Zeit schon mit dem fxc Compiler, als Beispiel habe ich aus der DirectX SDK folgendes Compiled Effect (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/tutorialsandsamples/compiledeffect.asp) genommmen.

aths
2004-06-09, 19:12:13
Da finde ich keinen HLSL-Source?!

pajofego
2004-06-09, 19:38:02
Original geschrieben von aths
Da finde ich keinen HLSL-Source?!

Also der HLSL code steckt in der Datei "CompiledEffect.fx", den Output aus dem fxc.exe Compiler findest du in "CompiledEffect.fxo".

In der Hilfe steht weiter unten:

Release: fxc /Tfx_2_0 /FoMyEffect.fxo MyEffect.fx
Debug: fxc /Od /Zi /Tfx_2_0 /FoMyEffect.fxo MyEffect.fx

Verwirrend, da eigentlich MyEffect.fx/o = CompiledEffect.fx/o
heissen sollte.

Willst du PixelShader oder VertexShader benutzen? Falls du Hilfe in Sachen PS 2.0 mit HLSL brauchst, fühl dich frei mich zu fragen. Bin am codden einer Physikengine mit HLSL und PS 2.0. Soll nicht heißen, dass ich da absolut wissend bin, aber die eine oder andere Sache habe ich schon geshadert :)

aths
2004-06-09, 19:53:35
Zwar habe ich das SDK installiert, aber keine CompiledEffect.fx auf der Festplatte.

pajofego
2004-06-09, 20:04:23
Original geschrieben von aths
Zwar habe ich das SDK installiert, aber keine CompiledEffect.fx auf der Festplatte.

Bist du dir auch sicher das summer update 2003 + all die dazugehörigen c++ tuts, samples usw. installiert zu haben?

aths
2004-06-09, 20:24:44
Da bin ich mir nicht sicher. Habe aber auch nur ein Modem.

pajofego
2004-06-09, 21:00:38
Original geschrieben von aths
Da bin ich mir nicht sicher. Habe aber auch nur ein Modem.

Modem, ist ein bischen schlecht, habe aber nachgeschaut, dass Beispiel ist definitv aus dem Summer update 2003. Ich denke, dass die meisten Samples mit HLSL aus dem Summer update stammt. Vielleicht wäre eine Installation sehr ratsam.

tb
2004-06-11, 17:29:16
-------------------------------------------------------------
// variables that are provided by the application
// -------------------------------------------------------------
const float4x4 matWorldViewProj;
const float4x4 matWorld;
const float4x4 matWorldIT;

const float4 EyeVector;
const float4 LightVector;

const float4 Ax = { 1.0f, 1.0f, 1.0f, 1.0f }; //ambient color
const float4 Dx = { 1.0f, 1.0f, 1.0f, 1.0f }; //diffuse color
const float4 Sx = { 1.0f, 1.0f, 1.0f, 1.0f }; //specular color
const float4 Lx = { 1.0f, 1.0f, 1.0f, 1.0f }; //light color

const float Ka = { 0.0125f }; //ambient coefficient
const float Kd = { 1.0f }; //diffuse coefficient

// -------------------------------------------------------------
// Output channels
// -------------------------------------------------------------
struct VS_OUTPUT
{
float4 Position : POSITION0;
float2 Tex : TEXCOORD0;
};

// -------------------------------------------------------------
// vertex shader function (input channels)
// -------------------------------------------------------------
VS_OUTPUT VS(float3 Position : POSITION0, float3 Normal : NORMAL, float2 Tex : TEXCOORD0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;

Out.Position = mul( float4(Position, 1.0), matWorldViewProj );

Out.Tex = Tex;

return Out;
}

// -------------------------------------------------------------
// Input channels
// -------------------------------------------------------------

struct PS_INPUT
{
float2 Tex : TEXCOORD0;
;

// -------------------------------------------------------------
// Pixel Shader (input channels):output channel
// -------------------------------------------------------------
float4 PS( PS_INPUT IN ) : COLOR
{
float3 color;

// color= sincos / sin - oder was immer du möchtest
return float4(color, 1.0);
}
//
einfach als shader.fx abspeichern

fxc.exe /T ps_2_0 /E PS /Fc ps_shader.txt shader.fx

fxc.exe /T vs_2_0 /E VS /Fc vs_shader.txt shader.fx


Thomas