port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type='text/xsl' href='_UpgradeReport_Files/UpgradeReport.xslt'?><UpgradeLog>
<Properties><Property Name="Solution" Value="ice">
</Property><Property Name="Solution File" Value="E:\programmierung\64k\ev10\ice\ice.sln">
</Property><Property Name="Date" Value="Samstag, 1. Mai 2010">
</Property><Property Name="Time" Value="22:16:47">
</Property></Properties><Event ErrorLevel="2" Project="ice" Source="src\ice.vcproj" Description="The following error has occurred during XML parsing:&#xA;&#xA;File: E:\programmierung\64k\ev10\ice\src\ice.vcproj&#xA;Line: 10&#xA;Column: 2&#xA;Error Message:&#xA;'9,00' verstößt gegen enumeration-Einschränkung von '7.00 7,00 7.10 7,10 8.00 8,00'.&#xA;Analyse des Attributs 'Version' mit dem Wert '9,00' fehlgeschlagen.&#xA;&#xA;The file 'E:\programmierung\64k\ev10\ice\src\ice.vcproj' has failed to load.">
</Event><Event ErrorLevel="2" Project="ice" Source="src\ice.vcproj" Description="Project upgrade failed.">
</Event><Event ErrorLevel="3" Project="ice" Source="src\ice.vcproj" Description="Not Converted">
</Event></UpgradeLog>

View File

@@ -0,0 +1,207 @@
BODY
{
BACKGROUND-COLOR: white;
FONT-FAMILY: "Verdana", sans-serif;
FONT-SIZE: 100%;
MARGIN-LEFT: 0px;
MARGIN-TOP: 0px
}
P
{
FONT-FAMILY: "Verdana", sans-serif;
FONT-SIZE: 70%;
LINE-HEIGHT: 12pt;
MARGIN-BOTTOM: 0px;
MARGIN-LEFT: 10px;
MARGIN-TOP: 10px
}
.note
{
BACKGROUND-COLOR: #ffffff;
COLOR: #336699;
FONT-FAMILY: "Verdana", sans-serif;
FONT-SIZE: 100%;
MARGIN-BOTTOM: 0px;
MARGIN-LEFT: 0px;
MARGIN-TOP: 0px;
PADDING-RIGHT: 10px
}
.infotable
{
BACKGROUND-COLOR: #f0f0e0;
BORDER-BOTTOM: #ffffff 0px solid;
BORDER-COLLAPSE: collapse;
BORDER-LEFT: #ffffff 0px solid;
BORDER-RIGHT: #ffffff 0px solid;
BORDER-TOP: #ffffff 0px solid;
FONT-SIZE: 70%;
MARGIN-LEFT: 10px
}
.issuetable
{
BACKGROUND-COLOR: #ffffe8;
BORDER-COLLAPSE: collapse;
COLOR: #000000;
FONT-SIZE: 100%;
MARGIN-BOTTOM: 10px;
MARGIN-LEFT: 13px;
MARGIN-TOP: 0px
}
.issuetitle
{
BACKGROUND-COLOR: #ffffff;
BORDER-BOTTOM: #dcdcdc 1px solid;
BORDER-TOP: #dcdcdc 1px;
COLOR: #003366;
FONT-WEIGHT: normal
}
.header
{
BACKGROUND-COLOR: #cecf9c;
BORDER-BOTTOM: #ffffff 1px solid;
BORDER-LEFT: #ffffff 1px solid;
BORDER-RIGHT: #ffffff 1px solid;
BORDER-TOP: #ffffff 1px solid;
COLOR: #000000;
FONT-WEIGHT: bold
}
.issuehdr
{
BACKGROUND-COLOR: #E0EBF5;
BORDER-BOTTOM: #dcdcdc 1px solid;
BORDER-TOP: #dcdcdc 1px solid;
COLOR: #000000;
FONT-WEIGHT: normal
}
.issuenone
{
BACKGROUND-COLOR: #ffffff;
BORDER-BOTTOM: 0px;
BORDER-LEFT: 0px;
BORDER-RIGHT: 0px;
BORDER-TOP: 0px;
COLOR: #000000;
FONT-WEIGHT: normal
}
.content
{
BACKGROUND-COLOR: #e7e7ce;
BORDER-BOTTOM: #ffffff 1px solid;
BORDER-LEFT: #ffffff 1px solid;
BORDER-RIGHT: #ffffff 1px solid;
BORDER-TOP: #ffffff 1px solid;
PADDING-LEFT: 3px
}
.issuecontent
{
BACKGROUND-COLOR: #ffffff;
BORDER-BOTTOM: #dcdcdc 1px solid;
BORDER-TOP: #dcdcdc 1px solid;
PADDING-LEFT: 3px
}
A:link
{
COLOR: #cc6633;
TEXT-DECORATION: underline
}
A:visited
{
COLOR: #cc6633;
}
A:active
{
COLOR: #cc6633;
}
A:hover
{
COLOR: #cc3300;
TEXT-DECORATION: underline
}
H1
{
BACKGROUND-COLOR: #003366;
BORDER-BOTTOM: #336699 6px solid;
COLOR: #ffffff;
FONT-SIZE: 130%;
FONT-WEIGHT: normal;
MARGIN: 0em 0em 0em -20px;
PADDING-BOTTOM: 8px;
PADDING-LEFT: 30px;
PADDING-TOP: 16px
}
H2
{
COLOR: #000000;
FONT-SIZE: 80%;
FONT-WEIGHT: bold;
MARGIN-BOTTOM: 3px;
MARGIN-LEFT: 10px;
MARGIN-TOP: 20px;
PADDING-LEFT: 0px
}
H3
{
COLOR: #000000;
FONT-SIZE: 80%;
FONT-WEIGHT: bold;
MARGIN-BOTTOM: -5px;
MARGIN-LEFT: 10px;
MARGIN-TOP: 20px
}
H4
{
COLOR: #000000;
FONT-SIZE: 70%;
FONT-WEIGHT: bold;
MARGIN-BOTTOM: 0px;
MARGIN-TOP: 15px;
PADDING-BOTTOM: 0px
}
UL
{
COLOR: #000000;
FONT-SIZE: 70%;
LIST-STYLE: square;
MARGIN-BOTTOM: 0pt;
MARGIN-TOP: 0pt
}
OL
{
COLOR: #000000;
FONT-SIZE: 70%;
LIST-STYLE: square;
MARGIN-BOTTOM: 0pt;
MARGIN-TOP: 0pt
}
LI
{
LIST-STYLE: square;
MARGIN-LEFT: 0px
}
.expandable
{
CURSOR: hand
}
.expanded
{
color: black
}
.collapsed
{
DISPLAY: none
}
.foot
{
BACKGROUND-COLOR: #ffffff;
BORDER-BOTTOM: #cecf9c 1px solid;
BORDER-TOP: #cecf9c 2px solid
}
.settings
{
MARGIN-LEFT: 25PX;
}
.help
{
TEXT-ALIGN: right;
margin-right: 10px;
}

View File

@@ -0,0 +1,232 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl='urn:schemas-microsoft-com:xslt'>
<xsl:key name="ProjectKey" match="Event" use="@Project" />
<xsl:template match="Events" mode="createProjects">
<projects>
<xsl:for-each select="Event">
<!--xsl:sort select="@Project" order="descending"/-->
<xsl:if test="(1=position()) or (preceding-sibling::*[1]/@Project != @Project)">
<xsl:variable name="ProjectName" select="@Project"/>
<project>
<xsl:attribute name="name">
<xsl:value-of select="@Project"/>
</xsl:attribute>
<xsl:if test="@Project=''">
<xsl:attribute name="solution">
<xsl:value-of select="@Solution"/>
</xsl:attribute>
</xsl:if>
<xsl:for-each select="key('ProjectKey', $ProjectName)">
<!--xsl:sort select="@Source" /-->
<xsl:if test="(1=position()) or (preceding-sibling::*[1]/@Source != @Source)">
<source>
<xsl:attribute name="name">
<xsl:value-of select="@Source"/>
</xsl:attribute>
<xsl:variable name="Source">
<xsl:value-of select="@Source"/>
</xsl:variable>
<xsl:for-each select="key('ProjectKey', $ProjectName)[ @Source = $Source ]">
<event>
<xsl:attribute name="error-level">
<xsl:value-of select="@ErrorLevel"/>
</xsl:attribute>
<xsl:attribute name="description">
<xsl:value-of select="@Description"/>
</xsl:attribute>
</event>
</xsl:for-each>
</source>
</xsl:if>
</xsl:for-each>
</project>
</xsl:if>
</xsl:for-each>
</projects>
</xsl:template>
<xsl:template match="projects">
<xsl:for-each select="project">
<xsl:sort select="@Name" order="ascending"/>
<h2>
<xsl:if test="@solution">Solution: <xsl:value-of select="@solution"/></xsl:if>
<xsl:if test="not(@solution)">Project: <xsl:value-of select="@name"/>
<xsl:for-each select="source">
<xsl:variable name="Hyperlink" select="@name"/>
<xsl:for-each select="event[@error-level='4']">
&#32;<A class="note"><xsl:attribute name="HREF"><xsl:value-of select="$Hyperlink"/></xsl:attribute><xsl:value-of select="@description"/></A>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</h2>
<table cellpadding="2" cellspacing="0" width="98%" border="1" bordercolor="white" class="infotable">
<tr>
<td nowrap="1" class="header" _locID="Filename">Filename</td>
<td nowrap="1" class="header" _locID="Status">Status</td>
<td nowrap="1" class="header" _locID="Errors">Errors</td>
<td nowrap="1" class="header" _locID="Warnings">Warnings</td>
</tr>
<xsl:for-each select="source">
<xsl:sort select="@name" order="ascending"/>
<xsl:variable name="source-id" select="generate-id(.)"/>
<xsl:if test="count(event)!=count(event[@error-level='4'])">
<tr class="row">
<td class="content">
<A HREF="javascript:"><xsl:attribute name="onClick">javascript:document.images['<xsl:value-of select="$source-id"/>'].click()</xsl:attribute><IMG border="0" alt="expand/collapse section" class="expandable" height="11" onclick="changepic()" src="_UpgradeReport_Files/UpgradeReport_Plus.gif" width="9" ><xsl:attribute name="name"><xsl:value-of select="$source-id"/></xsl:attribute><xsl:attribute name="child">src<xsl:value-of select="$source-id"/></xsl:attribute></IMG></A>&#32;<xsl:value-of select="@name"/>
</td>
<td class="content">
<xsl:if test="count(event[@error-level='3'])=1">
<xsl:for-each select="event[@error-level='3']">
<xsl:if test="@description='Converted'">Converted</xsl:if>
<xsl:if test="@description!='Converted'"><xsl:value-of select="@description"/></xsl:if>
</xsl:for-each>
</xsl:if>
<xsl:if test="count(event[@error-level='3'])!=1 and count(event[@error-level='3' and @description='Converted'])!=0">Converted
</xsl:if>
</td>
<td class="content"><xsl:value-of select="count(event[@error-level='2'])"/></td>
<td class="content"><xsl:value-of select="count(event[@error-level='1'])"/></td>
</tr>
<tr class="collapsed" bgcolor="#ffffff">
<xsl:attribute name="id">src<xsl:value-of select="$source-id"/></xsl:attribute>
<td colspan="7">
<table width="97%" border="1" bordercolor="#dcdcdc" rules="cols" class="issuetable">
<tr>
<td colspan="7" class="issuetitle" _locID="ConversionIssues">Conversion Issues - <xsl:value-of select="@name"/>:</td>
</tr>
<xsl:for-each select="event[@error-level!='3']">
<xsl:if test="@error-level!='4'">
<tr>
<td class="issuenone" style="border-bottom:solid 1 lightgray">
<xsl:value-of select="@description"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</td>
</tr>
</xsl:if>
</xsl:for-each>
<tr valign="top">
<td class="foot">
<xsl:if test="count(source)!=1">
<xsl:value-of select="count(source)"/> files
</xsl:if>
<xsl:if test="count(source)=1">
1 file
</xsl:if>
</td>
<td class="foot">
Converted: <xsl:value-of select="count(source/event[@error-level='3' and @description='Converted'])"/><BR />
Not converted <xsl:value-of select="count(source) - count(source/event[@error-level='3' and @description='Converted'])"/>
</td>
<td class="foot"><xsl:value-of select="count(source/event[@error-level='2'])"/></td>
<td class="foot"><xsl:value-of select="count(source/event[@error-level='1'])"/></td>
</tr>
</table>
</xsl:for-each>
</xsl:template>
<xsl:template match="Property">
<xsl:if test="@Name!='Date' and @Name!='Time' and @Name!='LogNumber' and @Name!='Solution'">
<tr><td nowrap="1"><b><xsl:value-of select="@Name"/>: </b><xsl:value-of select="@Value"/></td></tr>
</xsl:if>
</xsl:template>
<xsl:template match="UpgradeLog">
<html>
<head>
<META HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="_UpgradeReport_Files\UpgradeReport.css" />
<title>Conversion Report&#32;
<xsl:if test="Properties/Property[@Name='LogNumber']">
<xsl:value-of select="Properties/Property[@Name='LogNumber']/@Value"/>
</xsl:if>
</title>
<script language="javascript">
function outliner () {
oMe = window.event.srcElement
//get child element
var child = document.all[event.srcElement.getAttribute("child",false)];
//if child element exists, expand or collapse it.
if (null != child)
child.className = child.className == "collapsed" ? "expanded" : "collapsed";
}
function changepic() {
uMe = window.event.srcElement;
var check = uMe.src.toLowerCase();
if (check.lastIndexOf("upgradereport_plus.gif") != -1)
{
uMe.src = "_UpgradeReport_Files/UpgradeReport_Minus.gif"
}
else
{
uMe.src = "_UpgradeReport_Files/UpgradeReport_Plus.gif"
}
}
</script>
</head>
<body topmargin="0" leftmargin="0" rightmargin="0" onclick="outliner();">
<h1 _locID="ConversionReport">Conversion Report - <xsl:value-of select="Properties/Property[@Name='Solution']/@Value"/></h1>
<p><span class="note">
<b>Time of Conversion:</b>&#32;&#32;<xsl:value-of select="Properties/Property[@Name='Date']/@Value"/>&#32;&#32;<xsl:value-of select="Properties/Property[@Name='Time']/@Value"/><br/>
</span></p>
<xsl:variable name="SortedEvents">
<Events>
<xsl:for-each select="Event">
<xsl:sort select="@Project" order="ascending"/>
<xsl:sort select="@Source" order="ascending"/>
<xsl:sort select="@ErrorLevel" order="ascending"/>
<Event>
<xsl:attribute name="Project"><xsl:value-of select="@Project"/> </xsl:attribute>
<xsl:attribute name="Solution"><xsl:value-of select="/UpgradeLog/Properties/Property[@Name='Solution']/@Value"/> </xsl:attribute>
<xsl:attribute name="Source"><xsl:value-of select="@Source"/> </xsl:attribute>
<xsl:attribute name="ErrorLevel"><xsl:value-of select="@ErrorLevel"/> </xsl:attribute>
<xsl:attribute name="Description"><xsl:value-of select="@Description"/> </xsl:attribute>
</Event>
</xsl:for-each>
</Events>
</xsl:variable>
<xsl:variable name="Projects">
<xsl:apply-templates select="msxsl:node-set($SortedEvents)/*" mode="createProjects"/>
</xsl:variable>
<xsl:apply-templates select="msxsl:node-set($Projects)/*"/>
<p></p><p>
<table class="note">
<tr>
<td nowrap="1">
<b>Conversion Settings</b>
</td>
</tr>
<xsl:apply-templates select="Properties"/>
</table></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 B

View File

@@ -0,0 +1,11 @@
K 25
svn:wc:ra_dav:version-url
V 36
/svn/64k/!svn/ver/230/trunk/ev10/ice
END
ice.sln
K 25
svn:wc:ra_dav:version-url
V 44
/svn/64k/!svn/ver/229/trunk/ev10/ice/ice.sln
END

View File

@@ -0,0 +1,65 @@
9
dir
230
http://svn.xp-dev.com/svn/64k/trunk/ev10/ice
http://svn.xp-dev.com/svn/64k
2010-05-01T12:07:04.322967Z
230
dermark
svn:special svn:externals svn:needs-lock
e3c53db8-d867-4aff-9ce2-c1b2cf7253df
src
dir
ice.sln
file
2010-05-01T09:49:20.841204Z
9e27572d8e0bcdd2d9754b1dee7e9880
2010-05-01T09:49:20.841204Z
229
dermark
875

View File

@@ -0,0 +1 @@
9

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ice", "src/ice.vcproj", "{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}.Debug|Win32.ActiveCfg = Debug|Win32
{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}.Debug|Win32.Build.0 = Debug|Win32
{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}.Release|Win32.ActiveCfg = Release|Win32
{D91DFF9F-B3F5-4F75-AD44-19AD5F1DEB00}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

View File

@@ -0,0 +1,47 @@
K 25
svn:wc:ra_dav:version-url
V 40
/svn/64k/!svn/ver/230/trunk/ev10/ice/src
END
ice.cpp
K 25
svn:wc:ra_dav:version-url
V 48
/svn/64k/!svn/ver/230/trunk/ev10/ice/src/ice.cpp
END
grass.png
K 25
svn:wc:ra_dav:version-url
V 50
/svn/64k/!svn/ver/229/trunk/ev10/ice/src/grass.png
END
ice.vcproj
K 25
svn:wc:ra_dav:version-url
V 51
/svn/64k/!svn/ver/229/trunk/ev10/ice/src/ice.vcproj
END
shader.hlsl
K 25
svn:wc:ra_dav:version-url
V 52
/svn/64k/!svn/ver/230/trunk/ev10/ice/src/shader.hlsl
END
Lighthouse.jpg
K 25
svn:wc:ra_dav:version-url
V 55
/svn/64k/!svn/ver/229/trunk/ev10/ice/src/Lighthouse.jpg
END
debug.h
K 25
svn:wc:ra_dav:version-url
V 48
/svn/64k/!svn/ver/229/trunk/ev10/ice/src/debug.h
END
variables.h
K 25
svn:wc:ra_dav:version-url
V 52
/svn/64k/!svn/ver/229/trunk/ev10/ice/src/variables.h
END

View File

@@ -0,0 +1,266 @@
9
dir
230
http://svn.xp-dev.com/svn/64k/trunk/ev10/ice/src
http://svn.xp-dev.com/svn/64k
2010-05-01T12:07:04.322967Z
230
dermark
svn:special svn:externals svn:needs-lock
e3c53db8-d867-4aff-9ce2-c1b2cf7253df
ice.cpp
file
2010-05-01T12:07:04.322967Z
85279668b7959ecc10c428fc61703c58
2010-05-01T12:07:04.322967Z
230
dermark
11159
grass.png
file
2010-05-01T09:49:20.841204Z
bba7ccf74476748f9ad17a05563db4fb
2010-05-01T09:49:20.841204Z
229
dermark
has-props
781196
ice.vcproj
file
2010-05-01T09:49:20.841204Z
450a4a58cd0d664d77ad2d6e3bfaaa0b
2010-05-01T09:49:20.841204Z
229
dermark
5103
shader.hlsl
file
2010-05-01T12:07:04.322967Z
f1584e18b9f929c091ddd0719b6c589c
2010-05-01T12:07:04.322967Z
230
dermark
6954
Lighthouse.jpg
file
2010-05-01T09:49:20.841204Z
8969288f4245120e7c3870287cce0ff3
2010-05-01T09:49:20.841204Z
229
dermark
has-props
561276
debug.h
file
2010-05-01T09:49:20.841204Z
0f332f6f8582a1b44b809cf95b871113
2010-05-01T09:49:20.841204Z
229
dermark
504
variables.h
file
2010-05-01T09:49:20.841204Z
bd36b833b97fb613f946193aebac404a
2010-05-01T09:49:20.841204Z
229
dermark
954

View File

@@ -0,0 +1 @@
9

View File

@@ -0,0 +1,5 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

View File

@@ -0,0 +1,5 @@
K 13
svn:mime-type
V 24
application/octet-stream
END

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 KiB

View 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);
}

View 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>

View 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();
}
}

View 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};

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 763 KiB

View File

@@ -0,0 +1,312 @@
#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, "grass.png", &texture);
IDirect3DTexture9* backgroundTexture;
D3DXCreateTextureFromFile(d3dDevice, "Lighthouse.jpg", &backgroundTexture);
ID3DXEffect* effect = NULL;
ID3DXBuffer* errors = NULL;
DWORD hr = ::D3DXCreateEffectFromFile(d3dDevice, "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 = 3000;
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
{
//float t = (float)timeGetTime() / 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);
}

View 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>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
</assembly>

View File

@@ -0,0 +1 @@
Manifest resource last updated at 22:25:09,76 on 01.05.2010

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
</assembly>

View File

@@ -0,0 +1 @@
Manifest resource last updated at 23:36:18,48 on 01.05.2010

View File

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual C++ Express 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ice2005", "ice2005.vcproj", "{36076285-A206-4C90-9FA1-F5255CFF2810}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{36076285-A206-4C90-9FA1-F5255CFF2810}.Debug|Win32.ActiveCfg = Debug|Win32
{36076285-A206-4C90-9FA1-F5255CFF2810}.Debug|Win32.Build.0 = Debug|Win32
{36076285-A206-4C90-9FA1-F5255CFF2810}.Release|Win32.ActiveCfg = Release|Win32
{36076285-A206-4C90-9FA1-F5255CFF2810}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,179 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="ice2005"
ProjectGUID="{36076285-A206-4C90-9FA1-F5255CFF2810}"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d9.lib d3dx9.lib user32.lib winmm.lib"
GenerateDebugInformation="true"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d9.lib d3dx9.lib user32.lib winmm.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<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}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="8,00"
ShowAllFiles="false"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=".."
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="DC3GB"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory=".."
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="DC3GB"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

View 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();
}
}

View 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};