Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
122
GameTools/Zallad3D SceneClass/Shader_BumpSpecV.cpp
Normal file
122
GameTools/Zallad3D SceneClass/Shader_BumpSpecV.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
#include "Shader_BumpSpecV.h"
|
||||
#include "SceneManager.h"
|
||||
|
||||
CShader_BumpSpecV::CShader_BumpSpecV() {
|
||||
|
||||
// Vertex Shader Declare setting
|
||||
|
||||
DWORD vertexshaderdeclaration[]=
|
||||
{
|
||||
D3DVSD_STREAM(0),
|
||||
(D3DVSD_REG(0, D3DVSDT_FLOAT3)), // vertex position
|
||||
(D3DVSD_REG(1, D3DVSDT_FLOAT3)), // vertex normal
|
||||
(D3DVSD_REG(3, D3DVSDT_FLOAT2)), // vertex texture coord
|
||||
(D3DVSD_REG(5, D3DVSDT_FLOAT3)), // S
|
||||
(D3DVSD_REG(6, D3DVSDT_FLOAT3)), // T
|
||||
D3DVSD_END()
|
||||
};
|
||||
|
||||
// Create Vertex Shader
|
||||
|
||||
CreateVertexShader("c:/MP-project/Shaders/1_BumpDiffSpec.vsh",vertexshaderdeclaration);
|
||||
m_fBumpScale = 1.0f;
|
||||
|
||||
}
|
||||
CShader_BumpSpecV::~CShader_BumpSpecV() {
|
||||
|
||||
}
|
||||
void CShader_BumpSpecV::Apply() {
|
||||
CSceneManager::GetDevice()->SetVertexShader(m_dwVertexShader);
|
||||
SetupVertexShaderConstants();
|
||||
}
|
||||
|
||||
void CShader_BumpSpecV::SetupVertexShaderConstants() {
|
||||
|
||||
LPDIRECT3DDEVICE8 lpDevice = CSceneManager::GetDevice();
|
||||
lpDevice->SetVertexShaderConstant(CV_BUMP_SCALE, D3DXVECTOR4(0.0f, 0.0f, 0.0f, m_fBumpScale), 1);
|
||||
|
||||
// Shader constant setting
|
||||
/* *************
|
||||
LPDIRECT3DDEVICE8 lpDevice = CSceneManager::GetDevice();
|
||||
|
||||
lpDevice->SetVertexShaderConstant(CV_ZERO, D3DXVECTOR4(0.0f, 0.0f, 0.0f, 0.0f), 1);
|
||||
lpDevice->SetVertexShaderConstant(CV_ONE, D3DXVECTOR4(1.0f, 1.0f, 1.0f, 1.0f), 1);
|
||||
lpDevice->SetVertexShaderConstant(CV_HALF, D3DXVECTOR4(0.5f, 0.5f, 0.5f, 0.5f), 1);
|
||||
|
||||
// Matrix Set
|
||||
D3DXMATRIX matWorld,matView,matProject;
|
||||
lpDevice->GetTransform(D3DTS_WORLD,&matWorld);
|
||||
lpDevice->GetTransform(D3DTS_VIEW,&matView);
|
||||
lpDevice->GetTransform(D3DTS_PROJECTION,&matProject);
|
||||
|
||||
|
||||
D3DXMATRIX matTemp;
|
||||
|
||||
D3DXMATRIX matWorldView;
|
||||
D3DXMATRIX matInvWorldView;
|
||||
|
||||
D3DXMATRIX matWorldViewProj;
|
||||
|
||||
D3DXMATRIX matInvWorld;
|
||||
|
||||
D3DXMatrixMultiply(&matTemp, &matWorld, &matView);
|
||||
D3DXMatrixMultiply(&matWorldViewProj, &matTemp, &matProject);
|
||||
D3DXMatrixMultiply(&matWorldView, &matWorld, &matView);
|
||||
D3DXMatrixInverse(&matInvWorld, NULL, &matWorld);
|
||||
|
||||
D3DXMatrixInverse(&matInvWorldView, NULL, &matWorldView);
|
||||
|
||||
// Set World Camera Pos
|
||||
matrix *pmatPos = CSceneManager::m_ViewCamera->GetMatPosition();
|
||||
|
||||
D3DXVECTOR3 vecCamera3 = D3DXVECTOR3(pmatPos->_41,pmatPos->_42,pmatPos->_43);
|
||||
D3DXVECTOR4 vecCamera4 = D3DXVECTOR4(vecCamera3.x,vecCamera3.y,vecCamera3.z,0.0f);
|
||||
|
||||
lpDevice->SetVertexShaderConstant(CV_EYE_POS_WORLD, vecCamera4, 1);
|
||||
|
||||
|
||||
// Projection to clip space
|
||||
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLDVIEWPROJ_0, &matWorldViewProj(0, 0), 4);
|
||||
D3DXMatrixTranspose(&matWorldViewProj, &matWorldViewProj);
|
||||
|
||||
// Transform to eye space
|
||||
D3DXMatrixTranspose(&matWorldView, &matWorldView);
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLDVIEW_0, &matWorldView(0, 0), 4);
|
||||
D3DXMatrixTranspose(&matWorldView, &matWorldView);
|
||||
|
||||
// Transform to world space
|
||||
D3DXMatrixTranspose(&matWorld, &matWorld);
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLD_0, &matWorld(0, 0), 4);
|
||||
D3DXMatrixTranspose(&matWorld, &matWorld);
|
||||
|
||||
// Transform for normals
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLDVIEWIT_0, &matInvWorldView(0, 0), 1);
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLDVIEWIT_1, &matInvWorldView(1, 0), 1);
|
||||
lpDevice->SetVertexShaderConstant(CV_WORLDVIEWIT_2, &matInvWorldView(2, 0), 1);
|
||||
|
||||
// Set BumpScale
|
||||
lpDevice->SetVertexShaderConstant(CV_BUMP_SCALE, D3DXVECTOR4(0.0f, 0.0f, 0.0f, m_fBumpScale), 1);
|
||||
lpDevice->SetVertexShaderConstant(21, D3DXVECTOR4(1.0f,1.0f,1.0f,0.0f), 1);
|
||||
********************** */ // Set Light Directiom
|
||||
/*
|
||||
static int inc = 0;
|
||||
|
||||
static float fLightDistance = 0.95f;
|
||||
D3DXVECTOR3 vecLightDirection;
|
||||
D3DMATRIX *pmatV = CSceneManager::m_ViewCamera->GetMatView();
|
||||
|
||||
D3DXVECTOR3 vecFwd = D3DXVECTOR3(pmatV->_41,pmatV->_42,pmatV->_43) - vecCamera3;
|
||||
|
||||
|
||||
vecLightDirection = -vecFwd;
|
||||
D3DXVec3Normalize(&vecLightDirection,&vecLightDirection);
|
||||
|
||||
D3DXVECTOR4 vecLight = D3DXVECTOR4(vecLightDirection.x,vecLightDirection.y,vecLightDirection.z,1.0f);
|
||||
|
||||
|
||||
// Light Direction Setting
|
||||
lpDevice->SetVertexShaderConstant(21, vecLight, 1);
|
||||
*/
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user