port from perforce
This commit is contained in:
BIN
evoke-64k/ev10/ice/src/_svn/text-base/Lighthouse.jpg.svn-base
Normal file
BIN
evoke-64k/ev10/ice/src/_svn/text-base/Lighthouse.jpg.svn-base
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 548 KiB |
17
evoke-64k/ev10/ice/src/_svn/text-base/debug.h.svn-base
Normal file
17
evoke-64k/ev10/ice/src/_svn/text-base/debug.h.svn-base
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define COMPILE_SHADER(entry, profile, buffer) \
|
||||
{ \
|
||||
ID3DXBuffer* errors = 0; \
|
||||
D3DXCompileShader(shaderCode, shaderSize, 0, 0, entry, profile, D3DXSHADER_DEBUG, buffer, &errors, 0); \
|
||||
if (errors != 0) \
|
||||
{ \
|
||||
OutputDebugStringA((char*)errors->GetBufferPointer()); \
|
||||
errors->Release(); \
|
||||
DebugBreak(); \
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define COMPILE_SHADER(entry, profile, buffer) D3DXCompileShader(shaderCode, shaderSize, 0, 0, entry, profile, 0, buffer, 0, 0);
|
||||
#endif
|
||||
BIN
evoke-64k/ev10/ice/src/_svn/text-base/grass.png.svn-base
Normal file
BIN
evoke-64k/ev10/ice/src/_svn/text-base/grass.png.svn-base
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 763 KiB |
312
evoke-64k/ev10/ice/src/_svn/text-base/ice.cpp.svn-base
Normal file
312
evoke-64k/ev10/ice/src/_svn/text-base/ice.cpp.svn-base
Normal file
@@ -0,0 +1,312 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_EXTRA_LEAN
|
||||
#include <windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#include "variables.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
#pragma bss_seg("._fltused")
|
||||
extern "C" int _fltused = 0;
|
||||
|
||||
#define RENDER(c) \
|
||||
{\
|
||||
unsigned int passes;\
|
||||
effect->Begin(&passes, 0);\
|
||||
effect->BeginPass(0);\
|
||||
c;\
|
||||
effect->EndPass();\
|
||||
effect->End();\
|
||||
}
|
||||
|
||||
#pragma code_seg(".main")
|
||||
void main(void)
|
||||
{
|
||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||
devParams.hDeviceWindow = CreateWindowExA(0, "static", 0, WS_POPUP | WS_VISIBLE, 0, 0, screenX, screenY, 0, 0, 0, 0);
|
||||
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, devParams.hDeviceWindow, D3DCREATE_HARDWARE_VERTEXPROCESSING, &devParams, &d3dDevice);
|
||||
|
||||
IDirect3DTexture9* texture;
|
||||
D3DXCreateTextureFromFile(d3dDevice, L"grass.png", &texture);
|
||||
|
||||
IDirect3DTexture9* backgroundTexture;
|
||||
D3DXCreateTextureFromFile(d3dDevice, L"Lighthouse.jpg", &backgroundTexture);
|
||||
|
||||
ID3DXEffect* effect = NULL;
|
||||
ID3DXBuffer* errors = NULL;
|
||||
DWORD hr = ::D3DXCreateEffectFromFile(d3dDevice, L"shader.hlsl", NULL, NULL, D3DXSHADER_DEBUG, NULL, &effect, &errors);
|
||||
if (errors != 0 && hr != 0)
|
||||
{
|
||||
OutputDebugStringA((char*)errors->GetBufferPointer());
|
||||
errors->Release();
|
||||
DebugBreak();
|
||||
}
|
||||
if (effect == NULL)
|
||||
DebugBreak();
|
||||
|
||||
ShowCursor(0);
|
||||
|
||||
D3DVERTEXELEMENT9 decl[] =
|
||||
{
|
||||
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
|
||||
{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
|
||||
{1, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
|
||||
{1, 16, D3DDECLTYPE_FLOAT1, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 1},
|
||||
D3DDECL_END()
|
||||
};
|
||||
IDirect3DVertexDeclaration9* vertexDecl;
|
||||
d3dDevice->CreateVertexDeclaration(decl, &vertexDecl);
|
||||
|
||||
D3DVERTEXELEMENT9 quadDecl[] =
|
||||
{
|
||||
{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
|
||||
{0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
|
||||
D3DDECL_END() // this macro is needed as the last item!
|
||||
};
|
||||
IDirect3DVertexDeclaration9* quadVertexDecl;
|
||||
d3dDevice->CreateVertexDeclaration(quadDecl, &quadVertexDecl);
|
||||
|
||||
const unsigned int instanceCount = 5000;
|
||||
IDirect3DVertexBuffer9* instanceDataBuffer;
|
||||
InstanceData* instanceData;
|
||||
d3dDevice->CreateVertexBuffer(sizeof(InstanceData) * instanceCount, D3DUSAGE_WRITEONLY, D3DFVF_TEX1, D3DPOOL_MANAGED, &instanceDataBuffer, NULL);
|
||||
instanceDataBuffer->Lock(0, sizeof(InstanceData) * instanceCount, (void**)&instanceData, 0);//D3DLOCK_DISCARD);
|
||||
const float posFactor = 2.0f;
|
||||
for (int i = 0; i < instanceCount; ++i)
|
||||
{
|
||||
float r = (((rand() % 1000) / 1000.0f - 0.5f) + 2 ) * posFactor;
|
||||
float h = ((rand() % 1000) / 1000.0f - 0.5f) * posFactor * 0.5;
|
||||
float d = ((rand() % 1000) / 1000.0f - 0.5f) * 3.141 * 2;
|
||||
float x = sin(d) * r;
|
||||
float y = cos(d) * r;
|
||||
float z = h;
|
||||
|
||||
instanceData[i].pos[0] = x;
|
||||
instanceData[i].pos[1] = y;
|
||||
instanceData[i].pos[2] = z;
|
||||
instanceData[i].pos[3] = (r - 1.5) * 3 * (rand() % 900) / 900.0f + 0.1f; // scale
|
||||
instanceData[i].intensity = (((rand() % 1000) / 1000.0f)*0.2 + 0.01) * 0.1;
|
||||
}
|
||||
instanceDataBuffer->Unlock();
|
||||
|
||||
LPD3DXMESH sphereMesh;
|
||||
IDirect3DVertexBuffer9* sphereVertexBuffer;
|
||||
IDirect3DIndexBuffer9* sphereIndexBuffer;
|
||||
::D3DXCreateSphere(d3dDevice, 0.05f, 6, 6, &sphereMesh, NULL);
|
||||
sphereMesh->GetVertexBuffer(&sphereVertexBuffer);
|
||||
sphereMesh->GetIndexBuffer(&sphereIndexBuffer);
|
||||
|
||||
const int renderTextureCount = 4; // pos, normal, density, ballpos
|
||||
static LPDIRECT3DTEXTURE9 renderTexture[renderTextureCount];
|
||||
static LPDIRECT3DSURFACE9 renderSurface[renderTextureCount];
|
||||
|
||||
static LPDIRECT3DTEXTURE9 renderTexturePingPong[renderTextureCount * 2];
|
||||
static LPDIRECT3DSURFACE9 renderSurfacePingPong[renderTextureCount * 2];
|
||||
|
||||
const int renderTargetWidth = screenX;
|
||||
const int renderTargetHeight = screenY;
|
||||
|
||||
const float pingPongDevider = 2.0f;
|
||||
const D3DXVECTOR4 renderTargetDDX( 1.0f / renderTargetWidth, 1.0f / renderTargetHeight, 0.00f, 0.0f );
|
||||
const D3DXVECTOR4 renderTargetPingPongDDX( 1.0f / (renderTargetWidth / pingPongDevider), 1.0f / (renderTargetHeight / pingPongDevider), 0.00f, 0.0f );
|
||||
|
||||
for (int i = 0; i < renderTextureCount; ++i)
|
||||
{
|
||||
d3dDevice->CreateTexture(renderTargetWidth,
|
||||
renderTargetHeight,
|
||||
1,
|
||||
D3DUSAGE_RENDERTARGET,
|
||||
D3DFMT_A16B16G16R16F,
|
||||
D3DPOOL_DEFAULT,
|
||||
&renderTexture[i],
|
||||
NULL);
|
||||
renderTexture[i]->GetSurfaceLevel(0, &renderSurface[i]);
|
||||
|
||||
for (int k = 0; k < 2; ++k)
|
||||
{
|
||||
d3dDevice->CreateTexture(renderTargetWidth / pingPongDevider,
|
||||
renderTargetHeight / pingPongDevider,
|
||||
1,
|
||||
D3DUSAGE_RENDERTARGET,
|
||||
D3DFMT_A16B16G16R16F,
|
||||
D3DPOOL_DEFAULT,
|
||||
&renderTexturePingPong[i * 2 + k],
|
||||
NULL);
|
||||
renderTexturePingPong[i * 2 + k]->GetSurfaceLevel(0, &renderSurfacePingPong[i * 2 + k]);
|
||||
}
|
||||
}
|
||||
IDirect3DSurface9* pongPongDepthBuffer;
|
||||
hr = d3dDevice->CreateDepthStencilSurface(renderTargetWidth / pingPongDevider,
|
||||
renderTargetHeight / pingPongDevider, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, false, &pongPongDepthBuffer, NULL);
|
||||
|
||||
LPDIRECT3DSURFACE9 backBuffer = NULL;
|
||||
d3dDevice->GetRenderTarget(0, &backBuffer);
|
||||
IDirect3DSurface9* backBufferDepthBuffer;
|
||||
d3dDevice->GetDepthStencilSurface(&backBufferDepthBuffer);
|
||||
|
||||
d3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
effect->SetTexture("diffuseTexture", texture);
|
||||
effect->SetTexture("backgroundTexture", backgroundTexture);
|
||||
do
|
||||
{
|
||||
const float t = GetTickCount() / 1000.0f;
|
||||
|
||||
// Fill pos/depth and normal/matId
|
||||
D3DXMATRIX view;
|
||||
D3DXMATRIX proj;
|
||||
D3DXMATRIX viewProj;
|
||||
//D3DXVECTOR3 eye(0, 0, 10.0f);
|
||||
D3DXVECTOR3 eye(cos(t) * 10, sin(t) * 10, sin(t) * 10);
|
||||
//D3DXVECTOR3 eye(cos(t) * 10, sin(t) * 5, 5.0f);
|
||||
D3DXVECTOR4 eye4(eye.x, eye.y, eye.z, 0.0f);
|
||||
D3DXVECTOR3 at(0.0f, 0.0f, 0.0f);
|
||||
D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
|
||||
D3DXVECTOR3 right, direction;
|
||||
D3DXVec3Subtract(&direction, &at, &eye);
|
||||
D3DXVec3Normalize(&direction, &direction);
|
||||
D3DXVec3Cross(&right, &direction, &up);
|
||||
D3DXVec3Cross(&up, &right, &direction);
|
||||
D3DXMatrixLookAtLH(&view, &eye, &at, &up);
|
||||
D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 4.0f, 4.0f/3.0f, 1.0f, 100.0f);
|
||||
D3DXMatrixMultiply(&viewProj, &view, &proj);
|
||||
D3DXVECTOR4 direction4(direction.x, direction.y, direction.z, 0.0f);
|
||||
|
||||
effect->SetMatrix("viewProj", &viewProj);
|
||||
effect->SetVector("eye", &eye4);
|
||||
effect->SetVector("eyeDir", &direction4);
|
||||
|
||||
d3dDevice->SetStreamSource(0, sphereVertexBuffer, 0, sphereMesh->GetNumBytesPerVertex());
|
||||
d3dDevice->SetStreamSourceFreq(0, D3DSTREAMSOURCE_INDEXEDDATA | instanceCount);
|
||||
|
||||
d3dDevice->SetStreamSource(1, instanceDataBuffer, 0, sizeof(InstanceData));
|
||||
d3dDevice->SetStreamSourceFreq(1, D3DSTREAMSOURCE_INSTANCEDATA | 1ul);
|
||||
|
||||
d3dDevice->SetVertexDeclaration(vertexDecl);
|
||||
d3dDevice->SetIndices(sphereIndexBuffer);
|
||||
|
||||
// Begin
|
||||
{
|
||||
effect->SetTechnique("Deferred");
|
||||
|
||||
effect->SetTexture("positionTexture", NULL);
|
||||
effect->SetTexture("normalTexture", NULL);
|
||||
|
||||
d3dDevice->SetRenderTarget(0, renderSurface[0]);
|
||||
d3dDevice->SetRenderTarget(1, renderSurface[1]);
|
||||
|
||||
d3dDevice->BeginScene();
|
||||
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
|
||||
|
||||
RENDER(d3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, sphereMesh->GetNumVertices(), 0, sphereMesh->GetNumFaces()));
|
||||
|
||||
d3dDevice->EndScene();
|
||||
|
||||
/*d3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||
continue;*/
|
||||
}
|
||||
|
||||
{
|
||||
effect->SetTechnique("Density");
|
||||
|
||||
d3dDevice->SetRenderTarget(0, renderSurface[2]);
|
||||
d3dDevice->SetRenderTarget(1, NULL);
|
||||
|
||||
d3dDevice->BeginScene();
|
||||
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
|
||||
|
||||
RENDER(d3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, sphereMesh->GetNumVertices(), 0, sphereMesh->GetNumFaces()));
|
||||
|
||||
d3dDevice->EndScene();
|
||||
}
|
||||
|
||||
{
|
||||
effect->SetTechnique("ParticlePosition");
|
||||
|
||||
d3dDevice->SetRenderTarget(0, renderSurface[3]);
|
||||
d3dDevice->SetRenderTarget(1, NULL);
|
||||
|
||||
d3dDevice->BeginScene();
|
||||
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
|
||||
|
||||
RENDER(d3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, sphereMesh->GetNumVertices(), 0, sphereMesh->GetNumFaces()));
|
||||
|
||||
d3dDevice->EndScene();
|
||||
}
|
||||
|
||||
d3dDevice->SetStreamSourceFreq(0, 1);
|
||||
d3dDevice->SetStreamSourceFreq(1, 1);
|
||||
|
||||
d3dDevice->SetVertexDeclaration(quadVertexDecl);
|
||||
effect->SetVector("quadddx", &renderTargetPingPongDDX);
|
||||
|
||||
// blur
|
||||
{
|
||||
effect->SetTechnique("Blur");
|
||||
|
||||
for (int k = 0; k < 8; ++k)
|
||||
{
|
||||
d3dDevice->SetRenderTarget(0, renderSurfacePingPong[0 + ((k+1)%2)]);
|
||||
d3dDevice->SetRenderTarget(1, renderSurfacePingPong[2 + ((k+1)%2)]);
|
||||
d3dDevice->SetRenderTarget(2, renderSurfacePingPong[4 + ((k+1)%2)]);
|
||||
d3dDevice->SetRenderTarget(3, renderSurfacePingPong[6 + ((k+1)%2)]);
|
||||
|
||||
effect->SetVector("ddx", k == 0 ? &renderTargetDDX : &renderTargetPingPongDDX);
|
||||
effect->SetTexture("positionTexture", k == 0 ? renderTexture[0] : renderTexturePingPong[0 + k%2]);
|
||||
effect->SetTexture("normalTexture", k == 0 ? renderTexture[1] : renderTexturePingPong[2 + k%2]);
|
||||
effect->SetTexture("densityTexture", k == 0 ? renderTexture[2] : renderTexturePingPong[4 + k%2]);
|
||||
effect->SetTexture("particlePositionTexture", k == 0 ? renderTexture[3] : renderTexturePingPong[6 + k%2]);
|
||||
|
||||
d3dDevice->BeginScene();
|
||||
d3dDevice->Clear(0, NULL, D3DCLEAR_ZBUFFER, 0x0, 1.0f, 0);
|
||||
RENDER(d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadVerts, 20));
|
||||
d3dDevice->EndScene();
|
||||
}
|
||||
}
|
||||
|
||||
// Compose
|
||||
{
|
||||
if (GetAsyncKeyState(VK_SPACE))
|
||||
effect->SetTechnique("ComposeDebug");
|
||||
else
|
||||
effect->SetTechnique("Compose");
|
||||
|
||||
effect->SetTexture("positionTexture", renderTexturePingPong[1]);
|
||||
effect->SetTexture("normalTexture", renderTexturePingPong[3]);
|
||||
effect->SetTexture("densityTexture", renderTexturePingPong[5]);
|
||||
effect->SetTexture("particlePositionTexture", renderTexturePingPong[7]);
|
||||
|
||||
d3dDevice->SetRenderTarget(0, backBuffer);
|
||||
d3dDevice->SetRenderTarget(1, NULL);
|
||||
d3dDevice->SetRenderTarget(2, NULL);
|
||||
d3dDevice->SetRenderTarget(3, NULL);
|
||||
|
||||
d3dDevice->BeginScene();
|
||||
d3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFFF0000, 1.0f, 0);
|
||||
RENDER(d3dDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadVerts, 20));
|
||||
d3dDevice->EndScene();
|
||||
}
|
||||
|
||||
d3dDevice->Present(NULL, NULL, NULL, NULL);
|
||||
|
||||
// move particle
|
||||
instanceDataBuffer->Lock(0, sizeof(InstanceData) * instanceCount, (void**)&instanceData, 0);
|
||||
for (int i = 0; i < instanceCount; ++i)
|
||||
{
|
||||
D3DXVECTOR2 pos(instanceData[i].pos[0], instanceData[i].pos[1]);
|
||||
float r = D3DXVec2Length(&pos);
|
||||
float d = atan2(pos.x, pos.y);
|
||||
d += (r - 1.5) / 2.0 * 0.001;
|
||||
|
||||
float x = sin(d) * r;
|
||||
float y = cos(d) * r;
|
||||
|
||||
instanceData[i].pos[0] = x;
|
||||
instanceData[i].pos[1] = y;
|
||||
}
|
||||
instanceDataBuffer->Unlock();
|
||||
} while (!GetAsyncKeyState(VK_ESCAPE));
|
||||
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
238
evoke-64k/ev10/ice/src/_svn/text-base/ice.vcproj.svn-base
Normal file
238
evoke-64k/ev10/ice/src/_svn/text-base/ice.vcproj.svn-base
Normal file
@@ -0,0 +1,238 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="ice"
|
||||
ProjectGUID="{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}"
|
||||
RootNamespace="ice"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3d9.lib d3dx9.lib"
|
||||
OutputFile="$(OutDir)\$(ProjectName)D.exe"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile="$(TargetDir)$(TargetName).pdb"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
UseFAT32Workaround="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)bin"
|
||||
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
CommandLine=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="1"
|
||||
EnableIntrinsicFunctions="true"
|
||||
FavorSizeOrSpeed="2"
|
||||
OmitFramePointers="true"
|
||||
WholeProgramOptimization="false"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
|
||||
ExceptionHandling="0"
|
||||
RuntimeLibrary="2"
|
||||
BufferSecurityCheck="false"
|
||||
EnableFunctionLevelLinking="false"
|
||||
FloatingPointModel="2"
|
||||
ForceConformanceInForLoopScope="false"
|
||||
RuntimeTypeInfo="false"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="0"
|
||||
CallingConvention="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/CRINKLER /COMPMODE:SLOW /ORDERTRIES:1000 /HASHSIZE:200 /HASHTRIES:100 /REPORT:report.html"
|
||||
AdditionalDependencies="d3d9.lib d3dx9.lib"
|
||||
SuppressStartupBanner="false"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
LinkTimeCodeGeneration="0"
|
||||
EntryPointSymbol="main"
|
||||
RandomizedBaseAddress="0"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="0"
|
||||
ErrorReporting="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="false"
|
||||
UseFAT32Workaround="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\ice.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\debug.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\variables.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Lighthouse.jpg"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\texture.png"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\shader.hlsl"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Test.txt"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
330
evoke-64k/ev10/ice/src/_svn/text-base/shader.hlsl.svn-base
Normal file
330
evoke-64k/ev10/ice/src/_svn/text-base/shader.hlsl.svn-base
Normal file
@@ -0,0 +1,330 @@
|
||||
texture positionTexture;
|
||||
texture particlePositionTexture;
|
||||
texture normalTexture;
|
||||
texture densityTexture;
|
||||
texture diffuseTexture;
|
||||
texture backgroundTexture;
|
||||
|
||||
float4x4 viewProj;
|
||||
float2 ddx;
|
||||
float2 quadddx;
|
||||
float3 eye;
|
||||
float3 eyeDir;
|
||||
|
||||
sampler samplerPosition = sampler_state
|
||||
{
|
||||
Texture = <positionTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
sampler samplerParticlePosition = sampler_state
|
||||
{
|
||||
Texture = <particlePositionTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
sampler samplerNormal = sampler_state
|
||||
{
|
||||
Texture = <normalTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
sampler samplerDensity = sampler_state
|
||||
{
|
||||
Texture = <densityTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
sampler samplerDiffuse = sampler_state
|
||||
{
|
||||
Texture = <diffuseTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Wrap;
|
||||
AddressV = Wrap;
|
||||
};
|
||||
|
||||
sampler samplerBackground = sampler_state
|
||||
{
|
||||
Texture = <backgroundTexture>;
|
||||
MinFilter = Linear;
|
||||
MagFilter = Linear;
|
||||
AddressU = Clamp;
|
||||
AddressV = Clamp;
|
||||
};
|
||||
|
||||
struct SphereInput
|
||||
{
|
||||
float4 p:position;
|
||||
float3 n:normal;
|
||||
float4 i:texcoord0;
|
||||
float k:texcoord1;
|
||||
};
|
||||
|
||||
struct SphereOutput
|
||||
{
|
||||
float4 q:position;
|
||||
float3 n:normal;
|
||||
float4 p:texcoord0;
|
||||
float4 k:texcoord1;
|
||||
};
|
||||
|
||||
struct QuadInput
|
||||
{
|
||||
float4 p:position;
|
||||
float2 t:texcoord0;
|
||||
};
|
||||
|
||||
struct QuadOutput
|
||||
{
|
||||
float4 p:position;
|
||||
float2 t:texcoord0;
|
||||
float4 q:texcoord1;
|
||||
};
|
||||
|
||||
struct DeferredResult
|
||||
{
|
||||
float4 position : color0;
|
||||
float4 normal : color1;
|
||||
};
|
||||
|
||||
struct BlurResult
|
||||
{
|
||||
float4 position : color0;
|
||||
float4 normal : color1;
|
||||
float4 density : color2;
|
||||
float4 particlePosition : color3;
|
||||
};
|
||||
|
||||
|
||||
DeferredResult psDeferred(SphereOutput i)
|
||||
{
|
||||
DeferredResult result;
|
||||
result.normal = float4(i.n.xyz, 1);
|
||||
result.position = abs(float4(i.p.xyz, 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 psDensity(SphereOutput i) : color0
|
||||
{
|
||||
return i.k.a;
|
||||
}
|
||||
|
||||
float4 psParticlePosition(SphereOutput i) : color0
|
||||
{
|
||||
return i.k;
|
||||
}
|
||||
|
||||
void vsDeferred(SphereInput i, out SphereOutput o)
|
||||
{
|
||||
o.k.xyz = i.p.xyz * (1/0.05);
|
||||
o.k.a = i.k;
|
||||
|
||||
i.p.xyz *= i.i.w;
|
||||
i.p.x += i.i.x;
|
||||
i.p.y += i.i.y;
|
||||
i.p.z += i.i.z;
|
||||
|
||||
o.q = mul(i.p,viewProj);
|
||||
o.p = i.p;
|
||||
|
||||
o.n = i.n;
|
||||
}
|
||||
|
||||
BlurResult psBlur(QuadOutput input)
|
||||
{
|
||||
float2 SamplePos;
|
||||
int strength = 8;
|
||||
float thickness = 4;
|
||||
float pi4 = 3.141 * 2.0 / strength;
|
||||
|
||||
float4 resultNormal = 0;
|
||||
float4 resultPosition = 0;
|
||||
float4 resultDensity = 0;
|
||||
float4 resultParticlePosition = 0;
|
||||
int cnt = 0;
|
||||
for (int i = 0; i < strength; i++)
|
||||
{
|
||||
SamplePos = input.t + ddx * thickness * float2(sin(pi4 * i), cos(pi4 * i));
|
||||
|
||||
resultDensity += tex2D(samplerDensity, SamplePos);
|
||||
resultPosition += tex2D(samplerPosition, SamplePos);
|
||||
resultParticlePosition += tex2D(samplerParticlePosition, SamplePos);
|
||||
|
||||
float4 normal = tex2D(samplerNormal, SamplePos);
|
||||
resultNormal.a += normal.a;
|
||||
if (length(normal.xyz) > 0)
|
||||
{
|
||||
resultNormal.xyz += normal.xyz;
|
||||
cnt ++;
|
||||
}
|
||||
}
|
||||
resultNormal.a /= strength;
|
||||
if (cnt > 0)
|
||||
resultNormal.xyz = normalize(resultNormal.xyz / cnt);
|
||||
resultPosition /= strength;
|
||||
resultDensity /= strength;
|
||||
resultParticlePosition /= strength;
|
||||
|
||||
BlurResult result;
|
||||
result.normal = resultNormal;
|
||||
result.position = resultPosition;
|
||||
result.density = resultDensity;
|
||||
result.particlePosition = resultParticlePosition;
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 psComposeDebug(QuadOutput i):color0
|
||||
{
|
||||
float4 a = tex2D(samplerPosition, i.t);
|
||||
float4 b = tex2D(samplerNormal, i.t);
|
||||
float4 c = tex2D(samplerDensity, i.t);
|
||||
float4 d = tex2D(samplerParticlePosition, i.t);
|
||||
if (i.t.y > 0.5)
|
||||
{
|
||||
float len = length(b.xyz);
|
||||
if (len > 0)
|
||||
b.xyz /= len;
|
||||
if (i.t.x > 0.5)
|
||||
return b * a.a;
|
||||
if (b.a > 0)
|
||||
return float4(d.xyz, 1.0);
|
||||
return float4(1,0,0,1);
|
||||
}
|
||||
if (i.t.x > 0.5)
|
||||
return c;
|
||||
return a;
|
||||
}
|
||||
|
||||
QuadOutput vsCompose(QuadInput i)
|
||||
{
|
||||
QuadOutput o;
|
||||
i.p.xy *= 1.0 + quadddx;
|
||||
o.p = i.p;
|
||||
o.q = i.p;
|
||||
o.t = i.t;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 psCompose(QuadOutput i):color0
|
||||
{
|
||||
float4 density = tex2D(samplerDensity, i.t);
|
||||
float optDensity = min(1.0, max(0, density.a - 0.1) * 10);
|
||||
float4 particlePosition = tex2D(samplerParticlePosition, i.t);
|
||||
float4 a = tex2D(samplerPosition, i.t);
|
||||
float4 b = tex2D(samplerNormal, i.t);
|
||||
float3 lightPos = float3(10,10,10);
|
||||
float3 lightDir = normalize(float3(1,1,0));
|
||||
float3 normal = normalize(b.xyz);
|
||||
float3 position = a.xyz;
|
||||
|
||||
float3 vLightDir = normalize(lightPos - position); // calc LightDirection
|
||||
float fDiffuse = dot(normal, vLightDir); // get diffuse
|
||||
|
||||
float3 viewDir = normalize(a.xyz - eye);
|
||||
float3 vReflect = reflect(normal, lightDir);
|
||||
float fSpecular = dot(vReflect, normalize(viewDir));
|
||||
if (fSpecular > 0)
|
||||
fSpecular = pow( fSpecular, 4.0) * 4;
|
||||
else
|
||||
fSpecular = 0;
|
||||
|
||||
float fAtten = 10.0f;
|
||||
float LD = length(position - lightPos);
|
||||
fAtten *= 1.f/(0 +
|
||||
1*LD +
|
||||
0*LD*LD);
|
||||
fAtten = min(1.0f, fAtten);
|
||||
|
||||
float lighttransfer = 0.5;
|
||||
float4 diffuse = (tex2D(samplerDiffuse, particlePosition.xy / 10) + tex2D(samplerDiffuse, particlePosition.xz / 10)) * 0.5;
|
||||
diffuse = fAtten * lerp(fDiffuse, 1.0, min(1.0, 1.0 - optDensity + lighttransfer)) * diffuse + fAtten * fSpecular;
|
||||
float2 tex = i.t;
|
||||
|
||||
tex += normal.xy * optDensity * 0.05;
|
||||
float4 background = tex2D(samplerBackground, tex);
|
||||
return lerp(diffuse, background, 1.0-optDensity);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
technique Deferred
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsDeferred();
|
||||
PixelShader = compile ps_3_0 psDeferred();
|
||||
}
|
||||
}
|
||||
|
||||
technique Density
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsDeferred();
|
||||
PixelShader = compile ps_3_0 psDensity();
|
||||
AlphaBlendEnable= TRUE;
|
||||
SrcBlend = ONE;
|
||||
DestBlend = ONE;
|
||||
CullMode = CCW;
|
||||
ZEnable = true;
|
||||
ZFunc = ALWAYS;
|
||||
ZWriteEnable = false;
|
||||
}
|
||||
}
|
||||
|
||||
technique ParticlePosition
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsDeferred();
|
||||
PixelShader = compile ps_3_0 psParticlePosition();
|
||||
AlphaBlendEnable= TRUE;
|
||||
SrcBlend = ONE;
|
||||
DestBlend = ZERO;
|
||||
CullMode = CCW;
|
||||
ZEnable = true;
|
||||
ZFunc = LESSEQUAL ;
|
||||
ZWriteEnable = true;
|
||||
}
|
||||
}
|
||||
|
||||
technique Blur
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsCompose();
|
||||
PixelShader = compile ps_3_0 psBlur();
|
||||
}
|
||||
}
|
||||
|
||||
technique Compose
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsCompose();
|
||||
PixelShader = compile ps_3_0 psCompose();
|
||||
}
|
||||
}
|
||||
|
||||
technique ComposeDebug
|
||||
{
|
||||
pass P0
|
||||
{
|
||||
VertexShader = compile vs_3_0 vsCompose();
|
||||
PixelShader = compile ps_3_0 psComposeDebug();
|
||||
}
|
||||
}
|
||||
46
evoke-64k/ev10/ice/src/_svn/text-base/variables.h.svn-base
Normal file
46
evoke-64k/ev10/ice/src/_svn/text-base/variables.h.svn-base
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#pragma bss_seg(".nothing")
|
||||
static IDirect3DDevice9* d3dDevice;
|
||||
static IDirect3D9* d3d;
|
||||
|
||||
static ID3DXBuffer* buffer[4];
|
||||
static IDirect3DVertexShader9* vShader[4];
|
||||
static IDirect3DPixelShader9* pShader[4];
|
||||
|
||||
#pragma data_seg(".screenX")
|
||||
static const int screenX = 640;
|
||||
|
||||
#pragma data_seg(".screenY")
|
||||
static const int screenY = 480;
|
||||
|
||||
#pragma data_seg(".quadVerts")
|
||||
static const float quadVerts[30] =
|
||||
{
|
||||
-1.0f,-1.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
|
||||
-1.0f, 1.0f, 1.0f,
|
||||
0.0f, 0.0f,
|
||||
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
|
||||
1.0f, 1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
|
||||
-1.0f,-1.0f, 1.0f,
|
||||
0.0f, 1.0f,
|
||||
|
||||
1.0f, -1.0f, 1.0f,
|
||||
1.0f, 1.0f
|
||||
};
|
||||
|
||||
struct InstanceData
|
||||
{
|
||||
float pos[4];
|
||||
float intensity;
|
||||
};
|
||||
|
||||
#pragma data_seg(".devParams")
|
||||
static D3DPRESENT_PARAMETERS devParams = {screenX, screenY, D3DFMT_A8R8G8B8, 0, D3DMULTISAMPLE_NONE, 0, D3DSWAPEFFECT_DISCARD, 0, true, true, D3DFMT_D24S8, 0, 0, D3DPRESENT_INTERVAL_IMMEDIATE};
|
||||
Reference in New Issue
Block a user