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
*.obj
*.res
*.aps
*.aps

View File

@ -1,10 +1,29 @@
BUILD_TYPE ?= debug
all: $(BUILD_TYPE)/d3d10.exe
$(BUILD_TYPE)/d3d10.exe
PREFIX = i686-w64-mingw32-
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
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 = \
main.fxo \
@ -14,10 +33,10 @@ SHADERS = \
static.fxo
$(BUILD_TYPE)/%.res: %.rc $(SHADERS)
rc.exe /d "_UNICODE" /d "UNICODE" /fo $@ $<
$(WINDRES) -O coff -o $@ $<
$(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 = \
$(BUILD_TYPE)/robot_player.obj \
@ -28,5 +47,4 @@ OBJS = \
$(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
$(CXX) $(LDFLAGS) $(WOPT) -o $@ $(OBJS) -ld3dx10 -ld3d10

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

200
font.fx
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -97,6 +97,7 @@ ID3D10EffectShaderResourceVariable * g_pDiffuseVariableVolume = NULL;
// static
ID3D10Effect * g_pEffectStatic = NULL;
ID3D10EffectTechnique * g_pTechniqueStatic = NULL;
ID3D10EffectTechnique * g_pTechniqueStaticInstanced = NULL;
ID3D10InputLayout * g_pVertexLayoutStatic = NULL;
ID3D10EffectMatrixVariable * g_pWorldVariableStatic = NULL;
@ -747,6 +748,7 @@ HRESULT InitStaticEffect()
}
g_pTechniqueStatic = g_pEffectStatic->GetTechniqueByName("Static");
g_pTechniqueStaticInstanced = g_pEffectStatic->GetTechniqueByName("StaticInstanced");
//////////////////////////////////////////////////////////////////////
// layout
@ -1341,7 +1343,7 @@ static inline int sprint(LPCSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
char * end;
char * end = sprintbuf;
StringCbVPrintfExA(sprintbuf,
(sizeof (sprintbuf)),
&end,
@ -1568,6 +1570,42 @@ void RenderVolume(float t)
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()
@ -1607,8 +1645,8 @@ void Render()
//RenderBloom();
//print("%f\n", t);
RenderVolume(t);
//RenderVolumeMesh();
//RenderVolume(t);
RenderVolumeMesh();
// present
g_pSwapChain->Present(0, 0);

View File

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

View File

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

182
static.fx
View File

@ -1,73 +1,109 @@
matrix World;
matrix View;
matrix Projection;
matrix WorldNormal;
float3 vOutputColor;
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
struct PS_OUTPUT
{
float4 color0 : SV_TARGET0;
float4 color1 : SV_TARGET1;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul(input.Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Normal = mul(input.Normal, WorldNormal).xyz;
output.Tex = input.Tex;
return output;
}
PS_OUTPUT PS(PS_INPUT input)
{
PS_OUTPUT output;
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);
}
}
struct VS_INPUT
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
struct VS_INPUT_INSTANCED
{
float4 Pos : POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
row_major float4x4 mTransform : mTransform;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float2 Tex : TEXCOORD0;
};
struct PS_OUTPUT
{
float4 color0 : SV_TARGET0;
float4 color1 : SV_TARGET1;
};
cbuffer ceveryframe
{
matrix World;
matrix View;
matrix Projection;
matrix<float, 3, 3> WorldNormal;
};
cbuffer crarely
{
float3 vOutputColor;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul(input.Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Normal = mul(input.Normal, WorldNormal).xyz;
output.Tex = input.Tex;
return output;
}
PS_INPUT VSInstanced(VS_INPUT_INSTANCED input)
{
VS_INPUT input_vs = (VS_INPUT)0;
input_vs.Pos = mul(input.Pos, input.mTransform);
input_vs.Normal = input.Normal;
input_vs.Tex = input.Tex;
return VS(input_vs);
}
PS_OUTPUT PS(PS_INPUT input)
{
PS_OUTPUT output;
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;
Texture3D txDiffuse;
SamplerState samPoint {
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
struct VS_INPUT
{
float4 Pos : POSITION;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output;
output.Pos = float4(input.Pos.xy, 0, 1);
output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5);
return output;
}
float4 PS(PS_INPUT input) : SV_Target
{
float4 texColor = txDiffuse.Sample(samPoint, float3(input.Tex.xy, layer));
return float4(texColor.xxx, 1);
}
BlendState DisableBlending
{
BlendEnable[0] = False;
};
DepthStencilState DisableDepth
{
DepthEnable = FALSE;
DepthWriteMask = ZERO;
};
technique10 Volume
{
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(DisableDepth, 0);
}
}
float layer;
Texture3D txDiffuse;
SamplerState samPoint {
Filter = MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
struct VS_INPUT
{
float4 Pos : POSITION;
};
struct PS_INPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
PS_INPUT VS(VS_INPUT input)
{
PS_INPUT output;
output.Pos = float4(input.Pos.xy, 0, 1);
output.Tex = input.Pos.xy * float2(0.5, -0.5) + float2(0.5, 0.5);
return output;
}
float4 PS(PS_INPUT input) : SV_Target
{
float4 texColor = txDiffuse.Sample(samPoint, float3(input.Tex.xy, layer));
return float4(texColor.xxx, 1);
}
BlendState DisableBlending
{
BlendEnable[0] = False;
};
DepthStencilState DisableDepth
{
DepthEnable = FALSE;
DepthWriteMask = ZERO;
};
technique10 Volume
{
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(DisableDepth, 0);
}
}