Makefile: use GCC/mingw by default

This commit is contained in:
Zack Buhman 2026-01-13 11:29:03 -06:00
parent 2a46f6e550
commit 12e04e1f40
21 changed files with 3904 additions and 3817 deletions

2
.gitignore vendored
View File

@ -6,4 +6,4 @@
*.idb *.idb
*.obj *.obj
*.res *.res
*.aps *.aps

View File

@ -1,10 +1,29 @@
BUILD_TYPE ?= debug BUILD_TYPE ?= debug
all: $(BUILD_TYPE)/d3d10.exe PREFIX = i686-w64-mingw32-
$(BUILD_TYPE)/d3d10.exe WINDRES = $(PREFIX)windres
CXX = $(PREFIX)g++
OPT = -g -Og
CXXSTD += -std=gnu++14
CFLAGS += -Wall -Werror -Wfatal-errors
CFLAGS += -Wno-unused-but-set-variable
CXXFLAGS += -fno-exceptions
CFLAGS += -municode
WOPT += -municode
FXC ?= C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Utilities/bin/x86/fxc.exe
INCLUDE = \
-I./include
%.fxo: %.fx %.fxo: %.fx
fxc.exe @"shader_$(BUILD_TYPE).rsp" /T fx_4_0 /nologo /Fo $@ $< @echo fxc.exe @"shader_$(BUILD_TYPE).rsp" /T fx_4_0 /nologo /Fo $@ $<
@wine "$(FXC)" @"shader_$(BUILD_TYPE).rsp" /T fx_4_0 /nologo /Fo $@ $<
SHADERS = \ SHADERS = \
main.fxo \ main.fxo \
@ -14,10 +33,10 @@ SHADERS = \
static.fxo static.fxo
$(BUILD_TYPE)/%.res: %.rc $(SHADERS) $(BUILD_TYPE)/%.res: %.rc $(SHADERS)
rc.exe /d "_UNICODE" /d "UNICODE" /fo $@ $< $(WINDRES) -O coff -o $@ $<
$(BUILD_TYPE)/%.obj: src/%.cpp $(BUILD_TYPE)/%.obj: src/%.cpp
cl.exe /Fo"$@" /Fd"$(BUILD_TYPE)\vc80.pdb" @"compile_$(BUILD_TYPE).rsp" $< $(CXX) $(CXXSTD) $(CFLAGS) $(CXXFLAGS) $(WOPT) $(OPT) -o $@ $(INCLUDE) -c $<
OBJS = \ OBJS = \
$(BUILD_TYPE)/robot_player.obj \ $(BUILD_TYPE)/robot_player.obj \
@ -28,5 +47,4 @@ OBJS = \
$(BUILD_TYPE)/main.res $(BUILD_TYPE)/main.res
$(BUILD_TYPE)/d3d10.exe: $(OBJS) $(BUILD_TYPE)/d3d10.exe: $(OBJS)
link.exe /OUT:"$(BUILD_TYPE)\d3d10.exe" /PDB:"$(BUILD_TYPE)\d3d10.pdb" @"link_$(BUILD_TYPE).rsp" $(OBJS) /NOLOGO /ERRORREPORT:PROMPT $(CXX) $(LDFLAGS) $(WOPT) -o $@ $(OBJS) -ld3dx10 -ld3d10
mt.exe -manifest d3d10.exe.${BUILD_TYPE}.manifest -outputresource:$(BUILD_TYPE)\d3d10.exe;1 -nologo

View File

@ -1,37 +0,0 @@
BUILD_TYPE ?= debug
PREFIX = i686-w64-mingw32-
WINDRES = $(PREFIX)windres
CXX = $(PREFIX)g++
FXC = C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Utilities/bin/x86/fxc.exe
INCLUDE = \
-I./include
%.fxo: %.fx
wine "$(FXC)" @"shader_$(BUILD_TYPE).rsp" /T fx_4_0 /nologo /Fo $@ $<
SHADERS = \
main.fxo \
font.fxo \
volume.fxo \
bloom.fxo \
static.fxo
$(BUILD_TYPE)/%.res: %.rc $(SHADERS)
$(WINDRES) -O coff -o $@ $<
$(BUILD_TYPE)/%.obj: src/%.cpp
$(CXX) -municode -o $@ $(INCLUDE) -c $<
OBJS = \
$(BUILD_TYPE)/robot_player.obj \
$(BUILD_TYPE)/cube.obj \
$(BUILD_TYPE)/main.obj \
$(BUILD_TYPE)/print.obj \
$(BUILD_TYPE)/render_state.obj \
$(BUILD_TYPE)/main.res
$(BUILD_TYPE)/d3d10.exe: $(OBJS)
$(CXX) -municode -o $@ $(OBJS) -ld3dx10 -ld3d10

32
Makefile_msvc Normal file
View File

@ -0,0 +1,32 @@
BUILD_TYPE ?= debug
all: $(BUILD_TYPE)/d3d10.exe
$(BUILD_TYPE)/d3d10.exe
%.fxo: %.fx
fxc.exe @"shader_$(BUILD_TYPE).rsp" /T fx_4_0 /nologo /Fo $@ $<
SHADERS = \
main.fxo \
font.fxo \
volume.fxo \
bloom.fxo \
static.fxo
$(BUILD_TYPE)/%.res: %.rc $(SHADERS)
rc.exe /d "_UNICODE" /d "UNICODE" /fo $@ $<
$(BUILD_TYPE)/%.obj: src/%.cpp
cl.exe /Fo"$@" /Fd"$(BUILD_TYPE)\vc80.pdb" @"compile_$(BUILD_TYPE).rsp" $<
OBJS = \
$(BUILD_TYPE)/robot_player.obj \
$(BUILD_TYPE)/cube.obj \
$(BUILD_TYPE)/main.obj \
$(BUILD_TYPE)/print.obj \
$(BUILD_TYPE)/render_state.obj \
$(BUILD_TYPE)/main.res
$(BUILD_TYPE)/d3d10.exe: $(OBJS)
link.exe /OUT:"$(BUILD_TYPE)\d3d10.exe" /PDB:"$(BUILD_TYPE)\d3d10.pdb" @"link_$(BUILD_TYPE).rsp" $(OBJS) /NOLOGO /ERRORREPORT:PROMPT
mt.exe -manifest d3d10.exe.${BUILD_TYPE}.manifest -outputresource:$(BUILD_TYPE)\d3d10.exe;1 -nologo

224
bloom.fx
View File

@ -1,112 +1,112 @@
float2 vInvScreenSize; float2 vInvScreenSize;
float2 vDir; float2 vDir;
float fExposure; float fExposure;
Texture2D txDiffuseA; Texture2D txDiffuseA;
SamplerState samPoint { SamplerState samPoint {
Filter = MIN_MAG_MIP_LINEAR; Filter = MIN_MAG_MIP_LINEAR;
AddressU = CLAMP; AddressU = CLAMP;
AddressV = CLAMP; AddressV = CLAMP;
}; };
struct VS_INPUT struct VS_INPUT
{ {
float4 Pos : POSITION; float4 Pos : POSITION;
}; };
struct PS_INPUT struct PS_INPUT
{ {
float4 Pos : SV_POSITION; float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0; float2 Tex : TEXCOORD0;
}; };
PS_INPUT VS(VS_INPUT input) PS_INPUT VS(VS_INPUT input)
{ {
PS_INPUT output; PS_INPUT output;
output.Pos = input.Pos; output.Pos = input.Pos;
output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5); output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5);
return output; return output;
} }
static const float offset[6] = { static const float offset[6] = {
-4.1802892785260735, -4.1802892785260735,
-2.3013875682370335, -2.3013875682370335,
-0.45807799821605544, -0.45807799821605544,
1.3765284379445557, 1.3765284379445557,
3.2355245111649937, 3.2355245111649937,
5 5
}; };
static const float weight[6] = { static const float weight[6] = {
0.019171156084708173, 0.019171156084708173,
0.16924312602932176, 0.16924312602932176,
0.4273923867820408, 0.4273923867820408,
0.31401440082441, 0.31401440082441,
0.06672257638049649, 0.06672257638049649,
0.003456353899022774 0.003456353899022774
}; };
float4 PS(PS_INPUT input) : SV_Target float4 PS(PS_INPUT input) : SV_Target
{ {
float4 texColor = float4(0, 0, 0, 0); float4 texColor = float4(0, 0, 0, 0);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
float2 texOffset = vDir * offset[i] * vInvScreenSize; float2 texOffset = vDir * offset[i] * vInvScreenSize;
texColor += txDiffuseA.Sample(samPoint, input.Tex + texOffset) * weight[i]; texColor += txDiffuseA.Sample(samPoint, input.Tex + texOffset) * weight[i];
} }
return texColor; return texColor;
} }
BlendState DisableBlending BlendState DisableBlending
{ {
BlendEnable[0] = FALSE; BlendEnable[0] = FALSE;
}; };
BlendState EnableBlending BlendState EnableBlending
{ {
BlendEnable[0] = TRUE; BlendEnable[0] = TRUE;
SrcBlend = ONE; SrcBlend = ONE;
DestBlend = ONE; DestBlend = ONE;
BlendOp = ADD; BlendOp = ADD;
SrcBlendAlpha = ZERO; SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO; DestBlendAlpha = ZERO;
BlendOpAlpha = ADD; BlendOpAlpha = ADD;
}; };
DepthStencilState DisableDepth DepthStencilState DisableDepth
{ {
DepthEnable = FALSE; DepthEnable = FALSE;
DepthWriteMask = ZERO; DepthWriteMask = ZERO;
}; };
float4 PSBlend(PS_INPUT input) : SV_Target float4 PSBlend(PS_INPUT input) : SV_Target
{ {
float4 texColor = PS(input); float4 texColor = PS(input);
texColor = float4(1, 1, 1, 1) - exp2(-texColor * fExposure); texColor = float4(1, 1, 1, 1) - exp2(-texColor * fExposure);
return float4(texColor.xyz, 1); return float4(texColor.xyz, 1);
} }
technique10 Bloom technique10 Bloom
{ {
pass P0 pass P0
{ {
SetVertexShader(CompileShader(vs_4_0, VS())); SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL); SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS())); SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff); SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(DisableDepth, 0); SetDepthStencilState(DisableDepth, 0);
} }
} }
technique10 BloomBlend technique10 BloomBlend
{ {
pass P0 pass P0
{ {
SetVertexShader(CompileShader(vs_4_0, VS())); SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL); SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PSBlend())); SetPixelShader(CompileShader(ps_4_0, PSBlend()));
SetBlendState(EnableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff); SetBlendState(EnableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(DisableDepth, 0); SetDepthStencilState(DisableDepth, 0);
} }
} }

200
font.fx
View File

@ -1,100 +1,100 @@
float2 vInvScreenSize; float2 vInvScreenSize;
float2 vGlyphScale; float2 vGlyphScale;
float2 vTexScale; float2 vTexScale;
Texture2D txDiffuse; Texture2D txDiffuse;
SamplerState samPoint { SamplerState samPoint {
Filter = MIN_MAG_MIP_POINT; Filter = MIN_MAG_MIP_POINT;
AddressU = Wrap; AddressU = Wrap;
AddressV = Wrap; AddressV = Wrap;
}; };
struct VS_INPUT struct VS_INPUT
{ {
float4 Pos : TEXCOORD; float4 Pos : TEXCOORD;
}; };
struct GS_INPUT struct GS_INPUT
{ {
float4 Pos : SV_POSITION; float4 Pos : SV_POSITION;
}; };
struct PS_INPUT struct PS_INPUT
{ {
float4 Pos : SV_POSITION; float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0; float2 Tex : TEXCOORD0;
}; };
GS_INPUT VS(VS_INPUT input) GS_INPUT VS(VS_INPUT input)
{ {
GS_INPUT output; GS_INPUT output;
output.Pos = input.Pos; output.Pos = input.Pos;
return output; return output;
} }
static const float2 vertices[] = { static const float2 vertices[] = {
float2( 0.0f, 0.0f), // -- top right float2( 0.0f, 0.0f), // -- top right
float2( 1.0f, 0.0f), // -- top left float2( 1.0f, 0.0f), // -- top left
float2( 0.0f, -1.0f), // -- bottom right float2( 0.0f, -1.0f), // -- bottom right
float2( 1.0f, -1.0f), // -- bottom left float2( 1.0f, -1.0f), // -- bottom left
}; };
[maxvertexcount(4)] [maxvertexcount(4)]
void GS (point GS_INPUT input[1], inout TriangleStream<PS_INPUT> TriStream) void GS (point GS_INPUT input[1], inout TriangleStream<PS_INPUT> TriStream)
{ {
PS_INPUT output; PS_INPUT output;
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
float2 Pos; float2 Pos;
Pos = vertices[i] * vGlyphScale + input[0].Pos.xy; Pos = vertices[i] * vGlyphScale + input[0].Pos.xy;
Pos = Pos * vInvScreenSize + float2(-1, 1); Pos = Pos * vInvScreenSize + float2(-1, 1);
output.Pos = float4(Pos.xy, 0, 1); output.Pos = float4(Pos.xy, 0, 1);
output.Tex = vertices[i] * float2(1, -1); output.Tex = vertices[i] * float2(1, -1);
output.Tex = (output.Tex + input[0].Pos.zw) * vTexScale; output.Tex = (output.Tex + input[0].Pos.zw) * vTexScale;
TriStream.Append(output); TriStream.Append(output);
} }
TriStream.RestartStrip(); TriStream.RestartStrip();
} }
float4 PS(PS_INPUT input) : SV_Target float4 PS(PS_INPUT input) : SV_Target
{ {
float4 texColor = txDiffuse.Sample(samPoint, input.Tex); float4 texColor = txDiffuse.Sample(samPoint, input.Tex);
float c = texColor.x == 0 ? 0.0 : 1.0; float c = texColor.x == 0 ? 0.0 : 1.0;
return float4(c.xxx, 1); return float4(c.xxx, 1);
} }
BlendState EnableBlending BlendState EnableBlending
{ {
BlendEnable[0] = TRUE; BlendEnable[0] = TRUE;
SrcBlend = ONE; SrcBlend = ONE;
DestBlend = ONE; DestBlend = ONE;
BlendOp = ADD; BlendOp = ADD;
SrcBlendAlpha = ZERO; SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO; DestBlendAlpha = ZERO;
BlendOpAlpha = ADD; BlendOpAlpha = ADD;
}; };
DepthStencilState DisableDepth DepthStencilState DisableDepth
{ {
DepthEnable = FALSE; DepthEnable = FALSE;
DepthWriteMask = ZERO; DepthWriteMask = ZERO;
}; };
technique10 Font technique10 Font
{ {
pass P0 pass P0
{ {
SetVertexShader(CompileShader(vs_4_0, VS())); SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(CompileShader(gs_4_0, GS())); SetGeometryShader(CompileShader(gs_4_0, GS()));
SetPixelShader(CompileShader(ps_4_0, PS())); SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(EnableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff); SetBlendState(EnableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(DisableDepth, 0); SetDepthStencilState(DisableDepth, 0);
} }
} }

View File

@ -1,29 +1,29 @@
#ifndef _CUBE_HPP_ #ifndef _CUBE_HPP_
#define _CUBE_HPP_ #define _CUBE_HPP_
namespace cube { namespace cube {
extern const D3DXVECTOR3 accessor_0[]; extern const D3DXVECTOR3 accessor_0[];
const int accessor_0__length = 24; const int accessor_0__length = 24;
const int accessor_0__size = (sizeof (D3DXVECTOR3)) * 24; const int accessor_0__size = (sizeof (D3DXVECTOR3)) * 24;
extern const D3DXVECTOR3 accessor_1[]; extern const D3DXVECTOR3 accessor_1[];
const int accessor_1__length = 24; const int accessor_1__length = 24;
const int accessor_1__size = (sizeof (D3DXVECTOR3)) * 24; const int accessor_1__size = (sizeof (D3DXVECTOR3)) * 24;
extern const D3DXVECTOR2 accessor_2[]; extern const D3DXVECTOR2 accessor_2[];
const int accessor_2__length = 24; const int accessor_2__length = 24;
const int accessor_2__size = (sizeof (D3DXVECTOR2)) * 24; const int accessor_2__size = (sizeof (D3DXVECTOR2)) * 24;
extern const DWORD accessor_3[]; extern const DWORD accessor_3[];
const int accessor_3__length = 36; const int accessor_3__length = 36;
const int accessor_3__size = (sizeof (DWORD)) * 36; const int accessor_3__size = (sizeof (DWORD)) * 36;
extern const Node node_0; extern const Node node_0;
extern const Node * nodes[]; extern const Node * nodes[];
const int nodes__length = 1; const int nodes__length = 1;
} }
#endif #endif

View File

@ -1,8 +1,8 @@
#ifndef _GLOBALS_HPP_ #ifndef _GLOBALS_HPP_
#define _GLOBALS_HPP_ #define _GLOBALS_HPP_
extern HINSTANCE g_hInstance; extern HINSTANCE g_hInstance;
extern HWND g_hWnd; extern HWND g_hWnd;
extern ID3D10Device * g_pd3dDevice; extern ID3D10Device * g_pd3dDevice;
#endif #endif

View File

@ -1,62 +1,62 @@
#ifndef GLTF_HPP_ #ifndef GLTF_HPP_
#define GLTF_HPP_ #define GLTF_HPP_
struct Mesh { struct Mesh {
const D3DXVECTOR3 * position; const D3DXVECTOR3 * position;
const DWORD position_size; const DWORD position_size;
const D3DXVECTOR3 * normal; const D3DXVECTOR3 * normal;
const DWORD normal_size; const DWORD normal_size;
const D3DXVECTOR2 * texcoord_0; const D3DXVECTOR2 * texcoord_0;
const DWORD texcoord_0_size; const DWORD texcoord_0_size;
const D3DXVECTOR4 * weights_0; const D3DXVECTOR4 * weights_0;
const DWORD weights_0_size; const DWORD weights_0_size;
const D3DXVECTOR4 * joints_0; const D3DXVECTOR4 * joints_0;
const DWORD joints_0_size; const DWORD joints_0_size;
const DWORD * indices; const DWORD * indices;
const DWORD indices_size; const DWORD indices_size;
}; };
struct Skin; struct Skin;
struct Node { struct Node {
const DWORD parent_ix; const DWORD parent_ix;
const Skin * skin; // skin index (global) const Skin * skin; // skin index (global)
const Mesh * mesh; // mesh index (global) const Mesh * mesh; // mesh index (global)
const D3DXVECTOR3 translation; const D3DXVECTOR3 translation;
const D3DXQUATERNION rotation; const D3DXQUATERNION rotation;
const D3DXVECTOR3 scale; const D3DXVECTOR3 scale;
}; };
struct Skin { struct Skin {
const D3DXMATRIX * inverse_bind_matrices; // accessor const D3DXMATRIX * inverse_bind_matrices; // accessor
const int * joints; const int * joints;
DWORD joints_length; DWORD joints_length;
}; };
enum AnimationChannelPath { enum AnimationChannelPath {
ACP__WEIGHTS, ACP__WEIGHTS,
ACP__ROTATION, ACP__ROTATION,
ACP__TRANSLATION, ACP__TRANSLATION,
ACP__SCALE, ACP__SCALE,
}; };
struct AnimationSampler { struct AnimationSampler {
const float * input; // accessor index, containing keyframe timestamps const float * input; // accessor index, containing keyframe timestamps
const void * output; // accessor index, containing keyframe values (type depends on channel target path) const void * output; // accessor index, containing keyframe values (type depends on channel target path)
const int length; const int length;
}; };
struct AnimationChannel { struct AnimationChannel {
const AnimationSampler * sampler; // sampler index, this animation const AnimationSampler * sampler; // sampler index, this animation
struct { struct {
const int node_ix; const int node_ix;
const AnimationChannelPath path; // property to animate const AnimationChannelPath path; // property to animate
} target; } target;
}; };
#endif #endif

View File

@ -1,10 +1,10 @@
#ifndef GLTF_INSTANCE_HPP_ #ifndef GLTF_INSTANCE_HPP_
#define GLTF_INSTANCE_HPP_ #define GLTF_INSTANCE_HPP_
struct NodeInstance { struct NodeInstance {
D3DXVECTOR3 translation; D3DXVECTOR3 translation;
D3DXQUATERNION rotation; D3DXQUATERNION rotation;
D3DXVECTOR3 scale; D3DXVECTOR3 scale;
}; };
#endif #endif

View File

@ -1,7 +1,7 @@
#ifndef _PRINT_HPP_ #ifndef _PRINT_HPP_
#define _PRINT_HPP_ #define _PRINT_HPP_
void print(LPCSTR fmt, ...); void print(LPCSTR fmt, ...);
void printW(LPCWSTR fmt, ...); void printW(LPCWSTR fmt, ...);
#endif #endif

View File

@ -1,30 +1,30 @@
#ifndef _RENDER_STATE_HPP_ #ifndef _RENDER_STATE_HPP_
#define _RENDER_STATE_HPP_ #define _RENDER_STATE_HPP_
HRESULT LoadTexture2D(const wchar_t * resourceName, HRESULT LoadTexture2D(const wchar_t * resourceName,
const int width, const int width,
const int height, const int height,
const int pitch, const int pitch,
const DXGI_FORMAT format, const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView); ID3D10ShaderResourceView ** pTextureShaderResourceView);
HRESULT LoadTexture3D(const wchar_t * resourceName, HRESULT LoadTexture3D(const wchar_t * resourceName,
const int width, const int width,
const int height, const int height,
const int depth, const int depth,
const int pitch, const int pitch,
const int slicePitch, const int slicePitch,
const DXGI_FORMAT format, const DXGI_FORMAT format,
ID3D10ShaderResourceView ** pTextureShaderResourceView); ID3D10ShaderResourceView ** pTextureShaderResourceView);
HRESULT CreateTextureRenderTargetView(const int width, HRESULT CreateTextureRenderTargetView(const int width,
const int height, const int height,
ID3D10Texture2D ** pTexture, ID3D10Texture2D ** pTexture,
ID3D10RenderTargetView ** pRenderTargetView); ID3D10RenderTargetView ** pRenderTargetView);
HRESULT CreateTextureRenderTargetView(const int width, HRESULT CreateTextureRenderTargetView(const int width,
const int height, const int height,
ID3D10RenderTargetView ** pRenderTargetView, ID3D10RenderTargetView ** pRenderTargetView,
ID3D10ShaderResourceView ** pTextureShaderResourceView); ID3D10ShaderResourceView ** pTextureShaderResourceView);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,187 +1,187 @@
const DWORD accessor_0[] = { const DWORD accessor_0[] = {
0, 0,
1, 1,
3, 3,
0, 0,
3, 3,
2, 2,
2, 2,
3, 3,
5, 5,
2, 2,
5, 5,
4, 4,
4, 4,
5, 5,
7, 7,
4, 4,
7, 7,
6, 6,
6, 6,
7, 7,
9, 9,
6, 6,
9, 9,
8, 8,
}; };
const int accessor_0_length = (sizeof (accessor_0)) / (sizeof (accessor_0[0])); const int accessor_0_length = (sizeof (accessor_0)) / (sizeof (accessor_0[0]));
const D3DXVECTOR3 accessor_1[] = { const D3DXVECTOR3 accessor_1[] = {
D3DXVECTOR3(-0.5000000f, 0.0000000f, 0.0000000f), D3DXVECTOR3(-0.5000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR3( 0.5000000f, 0.0000000f, 0.0000000f), D3DXVECTOR3( 0.5000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR3(-0.5000000f, 0.5000000f, 0.0000000f), D3DXVECTOR3(-0.5000000f, 0.5000000f, 0.0000000f),
D3DXVECTOR3( 0.5000000f, 0.5000000f, 0.0000000f), D3DXVECTOR3( 0.5000000f, 0.5000000f, 0.0000000f),
D3DXVECTOR3(-0.5000000f, 1.0000000f, 0.0000000f), D3DXVECTOR3(-0.5000000f, 1.0000000f, 0.0000000f),
D3DXVECTOR3( 0.5000000f, 1.0000000f, 0.0000000f), D3DXVECTOR3( 0.5000000f, 1.0000000f, 0.0000000f),
D3DXVECTOR3(-0.5000000f, 1.5000000f, 0.0000000f), D3DXVECTOR3(-0.5000000f, 1.5000000f, 0.0000000f),
D3DXVECTOR3( 0.5000000f, 1.5000000f, 0.0000000f), D3DXVECTOR3( 0.5000000f, 1.5000000f, 0.0000000f),
D3DXVECTOR3(-0.5000000f, 2.0000000f, 0.0000000f), D3DXVECTOR3(-0.5000000f, 2.0000000f, 0.0000000f),
D3DXVECTOR3( 0.5000000f, 2.0000000f, 0.0000000f), D3DXVECTOR3( 0.5000000f, 2.0000000f, 0.0000000f),
}; };
const int accessor_1_length = (sizeof (accessor_1)) / (sizeof (accessor_1[0])); const int accessor_1_length = (sizeof (accessor_1)) / (sizeof (accessor_1[0]));
const D3DXVECTOR4 accessor_2[] = { const D3DXVECTOR4 accessor_2[] = {
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
}; };
const int accessor_2_length = (sizeof (accessor_2)) / (sizeof (accessor_2[0])); const int accessor_2_length = (sizeof (accessor_2)) / (sizeof (accessor_2[0]));
const D3DXVECTOR4 accessor_3[] = { const D3DXVECTOR4 accessor_3[] = {
D3DXVECTOR4( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.7500000f, 0.2500000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.7500000f, 0.2500000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.7500000f, 0.2500000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.7500000f, 0.2500000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.5000000f, 0.5000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.5000000f, 0.5000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.5000000f, 0.5000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.5000000f, 0.5000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.2500000f, 0.7500000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.2500000f, 0.7500000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.2500000f, 0.7500000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.2500000f, 0.7500000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f), D3DXVECTOR4( 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f),
}; };
const int accessor_3_length = (sizeof (accessor_3)) / (sizeof (accessor_3[0])); const int accessor_3_length = (sizeof (accessor_3)) / (sizeof (accessor_3[0]));
const D3DXMATRIX accessor_4[] = { const D3DXMATRIX accessor_4[] = {
D3DXMATRIX( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, D3DXMATRIX( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f,
0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f,
0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f),
D3DXMATRIX( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, D3DXMATRIX( 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f,
0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f,
0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f, 0.0000000f,
0.0000000f, -1.0000000f, 0.0000000f, 1.0000000f), 0.0000000f, -1.0000000f, 0.0000000f, 1.0000000f),
}; };
const int accessor_4_length = (sizeof (accessor_4)) / (sizeof (accessor_4[0])); const int accessor_4_length = (sizeof (accessor_4)) / (sizeof (accessor_4[0]));
const float accessor_5[] = { const float accessor_5[] = {
0.0, 0.0,
0.5, 0.5,
1.0, 1.0,
1.5, 1.5,
2.0, 2.0,
2.5, 2.5,
3.0, 3.0,
3.5, 3.5,
4.0, 4.0,
4.5, 4.5,
5.0, 5.0,
5.5, 5.5,
}; };
const int accessor_5_length = (sizeof (accessor_5)) / (sizeof (accessor_5[0])); const int accessor_5_length = (sizeof (accessor_5)) / (sizeof (accessor_5[0]));
const D3DXVECTOR4 accessor_6[] = { const D3DXVECTOR4 accessor_6[] = {
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.3830000f, 0.9240000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.3830000f, 0.9240000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.7070000f, 0.7070000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.7070000f, 0.7070000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.7070000f, 0.7070000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.7070000f, 0.7070000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.3830000f, 0.9240000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.3830000f, 0.9240000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.3830000f, 0.9240000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.3830000f, 0.9240000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.7070000f, 0.7070000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.7070000f, 0.7070000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.7070000f, 0.7070000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.7070000f, 0.7070000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.3830000f, 0.9240000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, -0.3830000f, 0.9240000f),
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f),
}; };
const int accessor_6_length = (sizeof (accessor_6)) / (sizeof (accessor_6[0])); const int accessor_6_length = (sizeof (accessor_6)) / (sizeof (accessor_6[0]));
const Mesh mesh_0 = { const Mesh mesh_0 = {
accessor_1, // position accessor_1, // position
(sizeof (accessor_1)), (sizeof (accessor_1)),
NULL, // normal NULL, // normal
0, 0,
NULL, // texcoord_0 NULL, // texcoord_0
0, 0,
accessor_3, // weights_0 accessor_3, // weights_0
(sizeof (accessor_3)), (sizeof (accessor_3)),
accessor_2, // joints_0 accessor_2, // joints_0
(sizeof (accessor_2)), (sizeof (accessor_2)),
accessor_0, // indices accessor_0, // indices
(sizeof (accessor_0)), (sizeof (accessor_0)),
}; };
extern const Skin skin_0; extern const Skin skin_0;
const Node node_0 = { const Node node_0 = {
&skin_0, // skin &skin_0, // skin
&mesh_0, // mesh &mesh_0, // mesh
D3DXVECTOR3( 0.0000000f, 0.0000000f, 0.0000000f), // translation D3DXVECTOR3( 0.0000000f, 0.0000000f, 0.0000000f), // translation
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation
D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale
}; };
const Node node_1 = { const Node node_1 = {
NULL, // skin NULL, // skin
NULL, // mesh NULL, // mesh
D3DXVECTOR3( 0.0000000f, 0.0000000f, 0.0000000f), // translation D3DXVECTOR3( 0.0000000f, 0.0000000f, 0.0000000f), // translation
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation
D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale
}; };
const Node node_2 = { const Node node_2 = {
NULL, // skin NULL, // skin
NULL, // mesh NULL, // mesh
D3DXVECTOR3( 0.0000000f, 1.0000000f, 0.0000000f), // translation D3DXVECTOR3( 0.0000000f, 1.0000000f, 0.0000000f), // translation
D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation D3DXVECTOR4( 0.0000000f, 0.0000000f, 0.0000000f, 1.0000000f), // rotation
D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale D3DXVECTOR3( 1.0000000f, 1.0000000f, 1.0000000f), // scale
}; };
const Node * skin_0__joints[] = { const Node * skin_0__joints[] = {
&node_1, &node_1,
&node_2, &node_2,
}; };
const Skin skin_0 = { const Skin skin_0 = {
accessor_4, // inverse bind matrices accessor_4, // inverse bind matrices
skin_0__joints, // joints skin_0__joints, // joints
2, // joints length 2, // joints length
}; };
const AnimationSampler animation_0__sampler_0 = { const AnimationSampler animation_0__sampler_0 = {
accessor_5, // input, keyframe timestamps accessor_5, // input, keyframe timestamps
accessor_6, // output, keyframe values (void *) accessor_6, // output, keyframe values (void *)
accessor_5_length, // length accessor_5_length, // length
}; };
const AnimationChannel animation_0__channels[] = { const AnimationChannel animation_0__channels[] = {
&animation_0__sampler_0, // animation sampler &animation_0__sampler_0, // animation sampler
{ {
&node_2, // target node &node_2, // target node
ACP__ROTATION, // target path ACP__ROTATION, // target path
}, },
}; };

View File

@ -52,8 +52,8 @@ PS_INPUT VS(VS_INPUT input)
output.Joint = input.Joint; output.Joint = input.Joint;
output.Tex = input.Tex; output.Tex = input.Tex;
output.Normal = mul(input.Normal, mSkin).xyz; output.Normal = mul(float4(input.Normal, 0), mSkin).xyz;
output.Normal = mul(output.Normal, World).xyz; output.Normal = mul(float4(output.Normal, 0), World).xyz;
return output; return output;
} }

View File

@ -1,2 +1,2 @@
/Od /Od
/Zi /Zi

View File

@ -97,6 +97,7 @@ ID3D10EffectShaderResourceVariable * g_pDiffuseVariableVolume = NULL;
// static // static
ID3D10Effect * g_pEffectStatic = NULL; ID3D10Effect * g_pEffectStatic = NULL;
ID3D10EffectTechnique * g_pTechniqueStatic = NULL; ID3D10EffectTechnique * g_pTechniqueStatic = NULL;
ID3D10EffectTechnique * g_pTechniqueStaticInstanced = NULL;
ID3D10InputLayout * g_pVertexLayoutStatic = NULL; ID3D10InputLayout * g_pVertexLayoutStatic = NULL;
ID3D10EffectMatrixVariable * g_pWorldVariableStatic = NULL; ID3D10EffectMatrixVariable * g_pWorldVariableStatic = NULL;
@ -747,6 +748,7 @@ HRESULT InitStaticEffect()
} }
g_pTechniqueStatic = g_pEffectStatic->GetTechniqueByName("Static"); g_pTechniqueStatic = g_pEffectStatic->GetTechniqueByName("Static");
g_pTechniqueStaticInstanced = g_pEffectStatic->GetTechniqueByName("StaticInstanced");
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// layout // layout
@ -1341,7 +1343,7 @@ static inline int sprint(LPCSTR fmt, ...)
{ {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
char * end; char * end = sprintbuf;
StringCbVPrintfExA(sprintbuf, StringCbVPrintfExA(sprintbuf,
(sizeof (sprintbuf)), (sizeof (sprintbuf)),
&end, &end,
@ -1568,6 +1570,42 @@ void RenderVolume(float t)
void RenderVolumeMesh() void RenderVolumeMesh()
{ {
const Mesh * mesh = cube::node_0.mesh;
int indices_length = mesh->indices_size / (sizeof (DWORD));
g_pViewVariableStatic->SetMatrix((float *)&g_View);
g_pProjectionVariableStatic->SetMatrix((float *)&g_Projection);
UINT stride[] = {
(sizeof (mesh->position[0])),
(sizeof (mesh->normal[0])),
(sizeof (mesh->texcoord_0[0])),
};
UINT offset[] = { 0, 0, 0 };
g_pd3dDevice->IASetInputLayout(g_pVertexLayoutStatic);
g_pd3dDevice->IASetVertexBuffers(0, g_dwVertexBufferCountCube, g_pVertexBufferCube, stride, offset);
g_pd3dDevice->IASetIndexBuffer(g_pIndexBufferCube, DXGI_FORMAT_R32_UINT, 0);
g_pd3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
D3D10_TECHNIQUE_DESC techDesc;
g_pTechniqueStatic->GetDesc(&techDesc);
D3DXMATRIX mWorldScale;
D3DXMATRIX mWorldTranslate;
D3DXMatrixScaling(&mWorldScale, 0.2f, 0.2f, 0.2f);
D3DXMatrixTranslation(&mWorldTranslate, 0.5f, 0.5f, 0.5f);
D3DXMATRIX mWorld = mWorldScale * mWorldTranslate;
g_pWorldVariableStatic->SetMatrix((float *)&mWorld);
D3DXMatrixIdentity(&mWorld);
g_pWorldNormalVariableStatic->SetMatrix((float *)&mWorld);
D3DXVECTOR4 vColor = D3DXVECTOR4(0.0f, 0.9f, 0.0f, 1.0f) ;
g_pOutputColorVariableStatic->SetFloatVector((float *)&vColor);
for (UINT p = 0; p < techDesc.Passes; p++) {
g_pTechniqueStatic->GetPassByIndex(p)->Apply(0);
g_pd3dDevice->DrawIndexed(indices_length, 0, 0);
}
} }
void Render() void Render()
@ -1607,8 +1645,8 @@ void Render()
//RenderBloom(); //RenderBloom();
//print("%f\n", t); //print("%f\n", t);
RenderVolume(t); //RenderVolume(t);
//RenderVolumeMesh(); RenderVolumeMesh();
// present // present
g_pSwapChain->Present(0, 0); g_pSwapChain->Present(0, 0);

View File

@ -18,10 +18,10 @@ void print(LPCSTR fmt, ...)
fmt, fmt,
args); args);
va_end(args); va_end(args);
size_t length = end - &buf[0];
#ifdef _DEBUG #ifdef _DEBUG
OutputDebugStringA(buf); OutputDebugStringA(buf);
#endif #endif
//size_t length = end - &buf[0];
//HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE); //HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//WriteConsoleA(hOutput, buf, (DWORD)length, NULL, NULL); //WriteConsoleA(hOutput, buf, (DWORD)length, NULL, NULL);
} }

View File

@ -25,7 +25,7 @@ HRESULT LoadTexture2D(const wchar_t * resourceName,
} }
DWORD dwResourceSize = SizeofResource(NULL, hRes); DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width); assert(pitch >= width);
assert(pitch * height == dwResourceSize); assert(pitch * height == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes); HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData; D3D10_SUBRESOURCE_DATA subresourceData;
@ -85,7 +85,7 @@ HRESULT LoadTexture3D(const wchar_t * resourceName,
DWORD dwResourceSize = SizeofResource(NULL, hRes); DWORD dwResourceSize = SizeofResource(NULL, hRes);
assert(pitch >= width); assert(pitch >= width);
assert(slicePitch >= depth); assert(slicePitch >= depth);
assert(slicePitch * depth == dwResourceSize); assert(slicePitch * depth == (int)dwResourceSize);
HGLOBAL hData = LoadResource(NULL, hRes); HGLOBAL hData = LoadResource(NULL, hRes);
D3D10_SUBRESOURCE_DATA subresourceData; D3D10_SUBRESOURCE_DATA subresourceData;

182
static.fx
View File

@ -1,73 +1,109 @@
matrix World; struct VS_INPUT
matrix View; {
matrix Projection; float4 Pos : POSITION;
float3 Normal : NORMAL;
matrix WorldNormal; float2 Tex : TEXCOORD0;
};
float3 vOutputColor;
struct VS_INPUT_INSTANCED
struct VS_INPUT {
{ float4 Pos : POSITION;
float4 Pos : POSITION; float3 Normal : NORMAL;
float3 Normal : NORMAL; float2 Tex : TEXCOORD0;
float2 Tex : TEXCOORD0; row_major float4x4 mTransform : mTransform;
}; };
struct PS_INPUT struct PS_INPUT
{ {
float4 Pos : SV_POSITION; float4 Pos : SV_POSITION;
float3 Normal : NORMAL; float3 Normal : NORMAL;
float2 Tex : TEXCOORD0; float2 Tex : TEXCOORD0;
}; };
struct PS_OUTPUT struct PS_OUTPUT
{ {
float4 color0 : SV_TARGET0; float4 color0 : SV_TARGET0;
float4 color1 : SV_TARGET1; float4 color1 : SV_TARGET1;
}; };
PS_INPUT VS(VS_INPUT input) cbuffer ceveryframe
{ {
PS_INPUT output = (PS_INPUT)0; matrix World;
matrix View;
output.Pos = mul(input.Pos, World); matrix Projection;
output.Pos = mul(output.Pos, View); matrix<float, 3, 3> WorldNormal;
output.Pos = mul(output.Pos, Projection); };
output.Normal = mul(input.Normal, WorldNormal).xyz; cbuffer crarely
{
output.Tex = input.Tex; float3 vOutputColor;
};
return output;
} PS_INPUT VS(VS_INPUT input)
{
PS_OUTPUT PS(PS_INPUT input) PS_INPUT output = (PS_INPUT)0;
{
PS_OUTPUT output; output.Pos = mul(input.Pos, World);
output.color0 = float4(vOutputColor, 1.0); output.Pos = mul(output.Pos, View);
output.color1 = float4(vOutputColor, 1.0); output.Pos = mul(output.Pos, Projection);
return output;
} output.Normal = mul(input.Normal, WorldNormal).xyz;
BlendState DisableBlending output.Tex = input.Tex;
{
BlendEnable[0] = FALSE; return output;
}; }
DepthStencilState EnableDepth PS_INPUT VSInstanced(VS_INPUT_INSTANCED input)
{ {
DepthEnable = TRUE; VS_INPUT input_vs = (VS_INPUT)0;
DepthWriteMask = ALL;
}; input_vs.Pos = mul(input.Pos, input.mTransform);
input_vs.Normal = input.Normal;
technique10 Static input_vs.Tex = input.Tex;
{
pass P0 return VS(input_vs);
{ }
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL); PS_OUTPUT PS(PS_INPUT input)
SetPixelShader(CompileShader(ps_4_0, PS())); {
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff); PS_OUTPUT output;
SetDepthStencilState(EnableDepth, 0); output.color0 = float4(vOutputColor, 1.0);
} output.color1 = float4(vOutputColor, 1.0);
} return output;
}
BlendState DisableBlending
{
BlendEnable[0] = FALSE;
};
DepthStencilState EnableDepth
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
};
technique10 Static
{
pass P0
{
SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(EnableDepth, 0);
}
}
technique10 StaticInstanced
{
pass P0
{
SetVertexShader(CompileShader(vs_4_0, VSInstanced()));
SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(EnableDepth, 0);
}
}

116
volume.fx
View File

@ -1,58 +1,58 @@
float layer; float layer;
Texture3D txDiffuse; Texture3D txDiffuse;
SamplerState samPoint { SamplerState samPoint {
Filter = MIN_MAG_MIP_LINEAR; Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap; AddressU = Wrap;
AddressV = Wrap; AddressV = Wrap;
}; };
struct VS_INPUT struct VS_INPUT
{ {
float4 Pos : POSITION; float4 Pos : POSITION;
}; };
struct PS_INPUT struct PS_INPUT
{ {
float4 Pos : SV_POSITION; float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0; float2 Tex : TEXCOORD0;
}; };
PS_INPUT VS(VS_INPUT input) PS_INPUT VS(VS_INPUT input)
{ {
PS_INPUT output; PS_INPUT output;
output.Pos = float4(input.Pos.xy, 0, 1); output.Pos = float4(input.Pos.xy, 0, 1);
output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5); output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5);
return output; return output;
} }
float4 PS(PS_INPUT input) : SV_Target float4 PS(PS_INPUT input) : SV_Target
{ {
float4 texColor = txDiffuse.Sample(samPoint, float3(input.Tex.xy, layer)); float4 texColor = txDiffuse.Sample(samPoint, float3(input.Tex.xy, layer));
return float4(texColor.xxx, 1); return float4(texColor.xxx, 1);
} }
BlendState DisableBlending BlendState DisableBlending
{ {
BlendEnable[0] = False; BlendEnable[0] = False;
}; };
DepthStencilState DisableDepth DepthStencilState DisableDepth
{ {
DepthEnable = FALSE; DepthEnable = FALSE;
DepthWriteMask = ZERO; DepthWriteMask = ZERO;
}; };
technique10 Volume technique10 Volume
{ {
pass P0 pass P0
{ {
SetVertexShader(CompileShader(vs_4_0, VS())); SetVertexShader(CompileShader(vs_4_0, VS()));
SetGeometryShader(NULL); SetGeometryShader(NULL);
SetPixelShader(CompileShader(ps_4_0, PS())); SetPixelShader(CompileShader(ps_4_0, PS()));
SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff); SetBlendState(DisableBlending, float4(0.0, 0.0, 0.0, 0.0), 0xffffffff);
SetDepthStencilState(DisableDepth, 0); SetDepthStencilState(DisableDepth, 0);
} }
} }