2008-09-07 10:29:46 +00:00
|
|
|
// Copyright (C) 2003-2008 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2008-10-04 22:47:28 +00:00
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "D3DShader.h"
|
|
|
|
#include "VertexShader.h"
|
|
|
|
#include "BPStructs.h"
|
|
|
|
|
2008-09-12 19:04:13 +00:00
|
|
|
static const char *genericVS = "// Generic Vertex Shader\
|
|
|
|
\n\
|
|
|
|
struct VS_INPUT {\n\
|
|
|
|
float4 pos : POSITION;\n\
|
|
|
|
float3 normal : NORMAL;\n\
|
|
|
|
float4 colors[2] : COLOR0;\n\
|
|
|
|
float3 uv[8] : TEXCOORD0;\n\
|
|
|
|
};\n\
|
|
|
|
\n\
|
|
|
|
struct VS_OUTPUT {\n\
|
|
|
|
float4 pos : POSITION;\n\
|
|
|
|
float4 colors[2] : COLOR0;\n\
|
|
|
|
//numtexgen\n\
|
|
|
|
float4 uv[5] : TEXCOORD0;\n\
|
|
|
|
};\n\
|
|
|
|
\n\
|
|
|
|
uniform matrix matWorldViewProj : register(c0);\n\
|
|
|
|
\n\
|
|
|
|
VS_OUTPUT main(const VS_INPUT input)\n\
|
|
|
|
{\n\
|
|
|
|
VS_OUTPUT output;\n\
|
|
|
|
\n\
|
|
|
|
output.pos = mul(matWorldViewProj, input.pos);\n\
|
|
|
|
// texgen\n\
|
2008-10-04 22:47:28 +00:00
|
|
|
for (int i=0; i<5; i++)\n\
|
|
|
|
output.uv[i] = float4(input.uv[i].xyz,1);\n\
|
2008-09-12 19:04:13 +00:00
|
|
|
\n\
|
|
|
|
for (int i=0; i<2; i++)\n output.colors[i] = input.colors[i];\n\
|
|
|
|
return output;\n\
|
|
|
|
}\0";
|
|
|
|
|
|
|
|
const char *GenerateVertexShader() {
|
|
|
|
return genericVS;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
|
2008-07-12 17:40:22 +00:00
|
|
|
char text2[65536];
|
|
|
|
#define WRITE p+=sprintf
|
|
|
|
|
|
|
|
void WriteTexgen(char *&p, int n);
|
|
|
|
|
2008-08-26 23:11:15 +00:00
|
|
|
const char *GenerateVertexShader()
|
2008-07-12 17:40:22 +00:00
|
|
|
{
|
|
|
|
int numColors = 2;
|
|
|
|
int numUV = 8;
|
|
|
|
int numTexgen = bpmem.genMode.numtexgens;
|
|
|
|
int numNormals = 3;
|
|
|
|
bool fogEnable = false;
|
|
|
|
bool hasNormal = true;
|
|
|
|
|
|
|
|
char *p = text2;
|
|
|
|
WRITE(p,"//Vertex Shader\n");
|
|
|
|
WRITE(p,"//%i uv->%i texgens, %i colors\n",numUV,numTexgen,numColors);
|
|
|
|
WRITE(p,"\n");
|
|
|
|
|
|
|
|
WRITE(p,"struct VS_INPUT {\n");
|
|
|
|
WRITE(p," float4 pos : POSITION;\n");
|
|
|
|
WRITE(p," float3 normal : NORMAL;\n");
|
|
|
|
if (numColors)
|
|
|
|
WRITE(p," float4 colors[%i] : COLOR0;\n",numColors);
|
|
|
|
if (numUV)
|
|
|
|
WRITE(p," float3 uv[%i] : TEXCOORD0;\n",numUV);
|
|
|
|
WRITE(p,"};\n");
|
|
|
|
WRITE(p,"\n");
|
|
|
|
|
|
|
|
WRITE(p,"struct VS_OUTPUT {\n");
|
|
|
|
WRITE(p," float4 pos : POSITION;\n");
|
|
|
|
WRITE(p," float4 colors[%i] : COLOR0;\n",numColors);
|
|
|
|
if (numTexgen)
|
|
|
|
WRITE(p," float4 uv[%i] : TEXCOORD0;\n",numTexgen);
|
|
|
|
if (fogEnable)
|
|
|
|
WRITE(p," float fog : FOG;\n",numTexgen);
|
|
|
|
WRITE(p,"};\n");
|
|
|
|
WRITE(p,"\n");
|
|
|
|
|
|
|
|
WRITE(p,"uniform matrix matWorldViewProj : register(c0);\n");
|
|
|
|
|
|
|
|
WRITE(p,"\n");
|
|
|
|
|
|
|
|
WRITE(p,"VS_OUTPUT main(const VS_INPUT input)\n");
|
|
|
|
WRITE(p,"{\n");
|
|
|
|
WRITE(p," VS_OUTPUT output;");
|
|
|
|
WRITE(p,"\n");
|
|
|
|
|
|
|
|
WRITE(p," output.pos = mul(matWorldViewProj, input.pos);\n");
|
|
|
|
|
|
|
|
for (int i = 0; i < (int)bpmem.genMode.numtexgens; i++)
|
|
|
|
{
|
|
|
|
//build the equation for this stage
|
|
|
|
WriteTexgen(p,i);
|
|
|
|
}
|
|
|
|
|
|
|
|
WRITE(p," for (int i=0; i<2; i++)\n output.colors[i] = input.colors[i];\n");
|
2008-08-27 12:44:22 +00:00
|
|
|
//WRITE(p," output.fog = 0.0f;");
|
2008-07-12 17:40:22 +00:00
|
|
|
WRITE(p,"return output;\n");
|
|
|
|
WRITE(p,"}\n");
|
|
|
|
WRITE(p,"\0");
|
|
|
|
|
|
|
|
// MessageBox(0,text2,0,0);
|
2008-08-26 23:11:15 +00:00
|
|
|
return text2;
|
2008-07-12 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* xform->vertexshader ideas
|
|
|
|
|
2008-09-12 19:04:13 +00:00
|
|
|
*//*
|
2008-07-12 17:40:22 +00:00
|
|
|
|
|
|
|
void WriteTexgen(char *&p, int n)
|
|
|
|
{
|
|
|
|
WRITE(p," output.uv[%i] = float4(input.uv[%i].xy,0,input.uv[%i].z);\n",n,n,n);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void WriteLight(int color, int component)
|
|
|
|
{
|
|
|
|
|
2008-09-12 19:04:13 +00:00
|
|
|
} */
|