13 BufferUpdater const& updater,
int select, std::shared_ptr<Material>
const& material,
14 std::shared_ptr<Lighting>
const& lighting, std::shared_ptr<LightCameraGeometry>
const& geometry)
16 LightingEffect(factory, updater, msVSSource[select & 1], msPSSource[select & 1],
17 material, lighting, geometry)
28 if ((select & 1) == 0)
80 " vec4 materialEmissive;\n" 81 " vec4 materialAmbient;\n" 82 " vec4 materialDiffuse;\n" 83 " vec4 materialSpecular;\n" 88 " vec4 lightingAmbient;\n" 89 " vec4 lightingDiffuse;\n" 90 " vec4 lightingSpecular;\n" 91 " vec4 lightingAttenuation;\n" 94 "uniform LightCameraGeometry\n" 96 " vec4 lightModelPosition;\n" 97 " vec4 cameraModelPosition;\n" 100 "layout(location = 0) in vec3 modelPosition;\n" 101 "layout(location = 1) in vec3 modelNormal;\n" 103 "layout(location = 0) out vec4 vertexColor;\n" 107 " vec3 modelLightDiff = modelPosition - lightModelPosition.xyz;\n" 108 " vec3 vertexDirection = normalize(modelLightDiff);\n" 109 " float NDotL = -dot(modelNormal, vertexDirection);\n" 110 " vec3 viewVector = normalize(cameraModelPosition.xyz - modelPosition);\n" 111 " vec3 halfVector = normalize(viewVector - vertexDirection);\n" 112 " float NDotH = dot(modelNormal, halfVector);\n" 113 " vec4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 115 " float distance = length(modelLightDiff);\n" 116 " float attenuation = lightingAttenuation.w / (lightingAttenuation.x + distance *\n" 117 " (lightingAttenuation.y + distance * lightingAttenuation.z));\n" 119 " vec3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 120 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 121 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 123 " vertexColor.rgb = materialEmissive.rgb + attenuation * color;\n" 124 " vertexColor.a = materialDiffuse.a;\n" 125 "#if GTE_USE_MAT_VEC\n" 126 " gl_Position = pvwMatrix * vec4(modelPosition, 1.0f);\n" 128 " gl_Position = vec4(modelPosition, 1.0f) * pvwMatrix;\n" 132 "uniform PVWMatrix\n" 137 "layout(location = 0) in vec3 modelPosition;\n" 138 "layout(location = 1) in vec3 modelNormal;\n" 140 "layout(location = 0) out vec3 vertexPosition;\n" 141 "layout(location = 1) out vec3 vertexNormal;\n" 145 " vertexPosition = modelPosition;\n" 146 " vertexNormal = modelNormal;\n" 147 "#if GTE_USE_MAT_VEC\n" 148 " gl_Position = pvwMatrix * vec4(modelPosition, 1.0f);\n" 150 " gl_Position = vec4(modelPosition, 1.0f) * pvwMatrix;\n" 157 "layout(location = 0) in vec4 vertexColor;\n" 159 "layout(location = 0) out vec4 pixelColor0;\n" 163 " pixelColor0 = vertexColor;\n" 169 " vec4 materialEmissive;\n" 170 " vec4 materialAmbient;\n" 171 " vec4 materialDiffuse;\n" 172 " vec4 materialSpecular;\n" 177 " vec4 lightingAmbient;\n" 178 " vec4 lightingDiffuse;\n" 179 " vec4 lightingSpecular;\n" 180 " vec4 lightingAttenuation;\n" 183 "uniform LightCameraGeometry\n" 185 " vec4 lightModelPosition;\n" 186 " vec4 cameraModelPosition;\n" 189 "layout(location = 0) in vec3 vertexPosition;\n" 190 "layout(location = 1) in vec3 vertexNormal;\n" 192 "layout(location = 0) out vec4 pixelColor0;\n" 196 " vec3 modelLightDiff = vertexPosition - lightModelPosition.xyz;\n" 197 " vec3 vertexDirection = normalize(modelLightDiff);\n" 198 " float NDotL = -dot(vertexNormal, vertexDirection);\n" 199 " vec3 viewVector = normalize(cameraModelPosition.xyz - vertexPosition.xyz);\n" 200 " vec3 halfVector = normalize(viewVector - vertexDirection);\n" 201 " float NDotH = dot(vertexNormal, halfVector);\n" 202 " vec4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 204 " float distance = length(modelLightDiff);\n" 205 " float attenuation = lightingAttenuation.w / (lightingAttenuation.x + distance *\n" 206 " (lightingAttenuation.y + distance * lightingAttenuation.z));\n" 208 " vec3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 209 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 210 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 212 " pixelColor0.rgb = materialEmissive.rgb + attenuation * color;\n" 213 " pixelColor0.a = materialDiffuse.a;\n" 219 "cbuffer PVWMatrix\n" 221 " float4x4 pvwMatrix;\n" 226 " float4 materialEmissive;\n" 227 " float4 materialAmbient;\n" 228 " float4 materialDiffuse;\n" 229 " float4 materialSpecular;\n" 234 " float4 lightingAmbient;\n" 235 " float4 lightingDiffuse;\n" 236 " float4 lightingSpecular;\n" 237 " float4 lightingAttenuation;\n" 240 "cbuffer LightCameraGeometry\n" 242 " float4 lightModelPosition;\n" 243 " float4 cameraModelPosition;\n" 248 " float3 modelPosition : POSITION;\n" 249 " float3 modelNormal : NORMAL;\n" 254 " float4 vertexColor : COLOR0;\n" 255 " float4 clipPosition : SV_POSITION;\n" 258 "VS_OUTPUT VSMain(VS_INPUT input)\n" 260 " VS_OUTPUT output;\n" 262 " float3 modelLightDiff = input.modelPosition - lightModelPosition.xyz;\n" 263 " float3 vertexDirection = normalize(modelLightDiff);\n" 264 " float NDotL = -dot(input.modelNormal, vertexDirection);\n" 265 " float3 viewVector = normalize(cameraModelPosition.xyz - input.modelPosition);\n" 266 " float3 halfVector = normalize(viewVector - vertexDirection);\n" 267 " float NDotH = dot(input.modelNormal, halfVector);\n" 268 " float4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 270 " float distance = length(modelLightDiff);\n" 271 " float attenuation = lightingAttenuation.w / (lightingAttenuation.x + distance *\n" 272 " (lightingAttenuation.y + distance * lightingAttenuation.z));\n" 274 " float3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 275 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 276 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 278 " output.vertexColor.rgb = materialEmissive.rgb + attenuation * color;\n" 279 " output.vertexColor.a = materialDiffuse.a;\n" 280 "#if GTE_USE_MAT_VEC\n" 281 " output.clipPosition = mul(pvwMatrix, float4(input.modelPosition, 1.0f));\n" 283 " output.clipPosition = mul(float4(input.modelPosition, 1.0f), pvwMatrix);\n" 290 " float4 vertexColor : COLOR0;\n" 295 " float4 pixelColor0 : SV_TARGET0;\n" 298 "PS_OUTPUT PSMain(PS_INPUT input)\n" 300 " PS_OUTPUT output;\n" 301 " output.pixelColor0 = input.vertexColor;\n" 305 "cbuffer PVWMatrix\n" 307 " float4x4 pvwMatrix;\n" 312 " float3 modelPosition : POSITION;\n" 313 " float3 modelNormal : NORMAL;\n" 318 " float3 vertexPosition : TEXCOORD0;\n" 319 " float3 vertexNormal : TEXCOORD1;\n" 320 " float4 clipPosition : SV_POSITION;\n" 323 "VS_OUTPUT VSMain(VS_INPUT input)\n" 325 " VS_OUTPUT output;\n" 327 " output.vertexPosition = input.modelPosition;\n" 328 " output.vertexNormal = input.modelNormal;\n" 329 "#if GTE_USE_MAT_VEC\n" 330 " output.clipPosition = mul(pvwMatrix, float4(input.modelPosition, 1.0f));\n" 332 " output.clipPosition = mul(float4(input.modelPosition, 1.0f), pvwMatrix);\n" 339 " float4 materialEmissive;\n" 340 " float4 materialAmbient;\n" 341 " float4 materialDiffuse;\n" 342 " float4 materialSpecular;\n" 347 " float4 lightingAmbient;\n" 348 " float4 lightingDiffuse;\n" 349 " float4 lightingSpecular;\n" 350 " float4 lightingAttenuation;\n" 353 "cbuffer LightCameraGeometry\n" 355 " float4 lightModelPosition;\n" 356 " float4 cameraModelPosition;\n" 361 " float3 vertexPosition : TEXCOORD0;\n" 362 " float3 vertexNormal : TEXCOORD1;\n" 367 " float4 pixelColor0 : SV_TARGET0;\n" 370 "PS_OUTPUT PSMain(PS_INPUT input)\n" 372 " PS_OUTPUT output;\n" 374 " float3 modelLightDiff = input.vertexPosition - lightModelPosition.xyz;\n" 375 " float3 vertexDirection = normalize(modelLightDiff);\n" 376 " float NDotL = -dot(input.vertexNormal, vertexDirection);\n" 377 " float3 viewVector = normalize(cameraModelPosition.xyz - input.vertexPosition.xyz);\n" 378 " float3 halfVector = normalize(viewVector - vertexDirection);\n" 379 " float NDotH = dot(input.vertexNormal, halfVector);\n" 380 " float4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 382 " float distance = length(modelLightDiff);\n" 383 " float attenuation = lightingAttenuation.w / (lightingAttenuation.x + distance *\n" 384 " (lightingAttenuation.y + distance * lightingAttenuation.z));\n" 386 " float3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 387 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 388 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 390 " output.pixelColor0.rgb = materialEmissive.rgb + attenuation * color;\n" 391 " output.pixelColor0.a = materialDiffuse.a;\n" static std::string const * msPSSource[2][ProgramFactory::PF_NUM_API]
virtual void UpdateMaterialConstant()
std::shared_ptr< Material > mMaterial
static std::string const * msVSSource[2][ProgramFactory::PF_NUM_API]
std::shared_ptr< LightCameraGeometry > mGeometry
PointLightEffect(std::shared_ptr< ProgramFactory > const &factory, BufferUpdater const &updater, int select, std::shared_ptr< Material > const &material, std::shared_ptr< Lighting > const &lighting, std::shared_ptr< LightCameraGeometry > const &geometry)
static std::string const msGLSLVSSource[2]
Vector4< float > cameraModelPosition
std::function< void(std::shared_ptr< Buffer > const &)> BufferUpdater
Vector4< float > emissive
std::shared_ptr< ConstantBuffer > mGeometryConstant
std::shared_ptr< Lighting > mLighting
virtual void UpdateGeometryConstant()
virtual void UpdateLightingConstant()
GLsizei const GLchar *const * string
std::shared_ptr< ConstantBuffer > mLightingConstant
static std::string GetShaderSourceLitFunctionGLSL()
static std::string const msGLSLPSSource[2]
virtual void UpdateGeometryConstant()
virtual void UpdateMaterialConstant()
Vector4< float > specular
virtual void UpdateLightingConstant()
std::shared_ptr< ConstantBuffer > mMaterialConstant
Vector4< float > lightModelPosition
Vector4< float > attenuation
static std::string const msHLSLSource[2]
std::shared_ptr< VisualProgram > mProgram
Vector4< float > specular