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 lightModelDirection;\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 " float NDotL = -dot(modelNormal, lightModelDirection.xyz);\n" 108 " vec3 viewVector = normalize(cameraModelPosition.xyz - modelPosition);\n" 109 " vec3 halfVector = normalize(viewVector - lightModelDirection.xyz);\n" 110 " float NDotH = dot(modelNormal, halfVector);\n" 111 " vec4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 113 " vec3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 114 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 115 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 117 " vertexColor.rgb = materialEmissive.rgb + lightingAttenuation.w * color;\n" 118 " vertexColor.a = materialDiffuse.a;\n" 119 "#if GTE_USE_MAT_VEC\n" 120 " gl_Position = pvwMatrix * vec4(modelPosition, 1.0f);\n" 122 " gl_Position = vec4(modelPosition, 1.0f) * pvwMatrix;\n" 126 "uniform PVWMatrix\n" 131 "layout(location = 0) in vec3 modelPosition;\n" 132 "layout(location = 1) in vec3 modelNormal;\n" 134 "layout(location = 0) out vec3 vertexPosition;\n" 135 "layout(location = 1) out vec3 vertexNormal;\n" 139 " vertexPosition = modelPosition;\n" 140 " vertexNormal = modelNormal;\n" 141 "#if GTE_USE_MAT_VEC\n" 142 " gl_Position = pvwMatrix * vec4(modelPosition, 1.0f);\n" 144 " gl_Position = vec4(modelPosition, 1.0f) * pvwMatrix;\n" 151 "layout(location = 0) in vec4 vertexColor;\n" 153 "layout(location = 0) out vec4 pixelColor0;\n" 157 " pixelColor0 = vertexColor;\n" 163 " vec4 materialEmissive;\n" 164 " vec4 materialAmbient;\n" 165 " vec4 materialDiffuse;\n" 166 " vec4 materialSpecular;\n" 171 " vec4 lightingAmbient;\n" 172 " vec4 lightingDiffuse;\n" 173 " vec4 lightingSpecular;\n" 174 " vec4 lightingAttenuation;\n" 177 "uniform LightCameraGeometry\n" 179 " vec4 lightModelDirection;\n" 180 " vec4 cameraModelPosition;\n" 183 "layout(location = 0) in vec3 vertexPosition;\n" 184 "layout(location = 1) in vec3 vertexNormal;\n" 186 "layout(location = 0) out vec4 pixelColor0;\n" 190 " vec3 normal = normalize(vertexNormal);\n" 191 " float NDotL = -dot(normal, lightModelDirection.xyz);\n" 192 " vec3 viewVector = normalize(cameraModelPosition.xyz - vertexPosition);\n" 193 " vec3 halfVector = normalize(viewVector - lightModelDirection.xyz);\n" 194 " float NDotH = dot(normal, halfVector);\n" 195 " vec4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 197 " vec3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 198 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 199 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 201 " pixelColor0.rgb = materialEmissive.rgb + lightingAttenuation.w * color;\n" 202 " pixelColor0.a = materialDiffuse.a;\n" 208 "cbuffer PVWMatrix\n" 210 " float4x4 pvwMatrix;\n" 215 " float4 materialEmissive;\n" 216 " float4 materialAmbient;\n" 217 " float4 materialDiffuse;\n" 218 " float4 materialSpecular;\n" 223 " float4 lightingAmbient;\n" 224 " float4 lightingDiffuse;\n" 225 " float4 lightingSpecular;\n" 226 " float4 lightingAttenuation;\n" 229 "cbuffer LightCameraGeometry\n" 231 " float4 lightModelDirection;\n" 232 " float4 cameraModelPosition;\n" 237 " float3 modelPosition : POSITION;\n" 238 " float3 modelNormal : NORMAL;\n" 243 " float4 vertexColor : COLOR0;\n" 244 " float4 clipPosition : SV_POSITION;\n" 247 "VS_OUTPUT VSMain(VS_INPUT input)\n" 249 " VS_OUTPUT output;\n" 251 " float NDotL = -dot(input.modelNormal, lightModelDirection.xyz);\n" 252 " float3 viewVector = normalize(cameraModelPosition.xyz - input.modelPosition);\n" 253 " float3 halfVector = normalize(viewVector - lightModelDirection.xyz);\n" 254 " float NDotH = dot(input.modelNormal, halfVector);\n" 255 " float4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 257 " float3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 258 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 259 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 261 " output.vertexColor.rgb = materialEmissive.rgb + lightingAttenuation.w * color;\n" 262 " output.vertexColor.a = materialDiffuse.a;\n" 263 "#if GTE_USE_MAT_VEC\n" 264 " output.clipPosition = mul(pvwMatrix, float4(input.modelPosition, 1.0f));\n" 266 " output.clipPosition = mul(float4(input.modelPosition, 1.0f), pvwMatrix);\n" 273 " float4 vertexColor : COLOR0;\n" 278 " float4 pixelColor0 : SV_TARGET0;\n" 281 "PS_OUTPUT PSMain(PS_INPUT input)\n" 283 " PS_OUTPUT output;\n" 284 " output.pixelColor0 = input.vertexColor;\n" 288 "cbuffer PVWMatrix\n" 290 " float4x4 pvwMatrix;\n" 295 " float3 modelPosition : POSITION;\n" 296 " float3 modelNormal : NORMAL;\n" 301 " float3 vertexPosition : TEXCOORD0;\n" 302 " float3 vertexNormal : TEXCOORD1;\n" 303 " float4 clipPosition : SV_POSITION;\n" 306 "VS_OUTPUT VSMain(VS_INPUT input)\n" 308 " VS_OUTPUT output;\n" 310 " output.vertexPosition = input.modelPosition;\n" 311 " output.vertexNormal = input.modelNormal;\n" 312 "#if GTE_USE_MAT_VEC\n" 313 " output.clipPosition = mul(pvwMatrix, float4(input.modelPosition, 1.0f));\n" 315 " output.clipPosition = mul(float4(input.modelPosition, 1.0f), pvwMatrix);\n" 322 " float4 materialEmissive;\n" 323 " float4 materialAmbient;\n" 324 " float4 materialDiffuse;\n" 325 " float4 materialSpecular;\n" 330 " float4 lightingAmbient;\n" 331 " float4 lightingDiffuse;\n" 332 " float4 lightingSpecular;\n" 333 " float4 lightingAttenuation;\n" 336 "cbuffer LightCameraGeometry\n" 338 " float4 lightModelDirection;\n" 339 " float4 cameraModelPosition;\n" 344 " float3 vertexPosition : TEXCOORD0;\n" 345 " float3 vertexNormal : TEXCOORD1;\n" 350 " float4 pixelColor0 : SV_TARGET0;\n" 353 "PS_OUTPUT PSMain(PS_INPUT input)\n" 355 " PS_OUTPUT output;\n" 357 " float3 normal = normalize(input.vertexNormal);\n" 358 " float NDotL = -dot(normal, lightModelDirection.xyz);\n" 359 " float3 viewVector = normalize(cameraModelPosition.xyz - input.vertexPosition);\n" 360 " float3 halfVector = normalize(viewVector - lightModelDirection.xyz);\n" 361 " float NDotH = dot(normal, halfVector);\n" 362 " float4 lighting = lit(NDotL, NDotH, materialSpecular.a);\n" 364 " float3 color = materialAmbient.rgb * lightingAmbient.rgb +\n" 365 " lighting.y * materialDiffuse.rgb * lightingDiffuse.rgb +\n" 366 " lighting.z * materialSpecular.rgb * lightingSpecular.rgb;\n" 368 " output.pixelColor0.rgb = materialEmissive.rgb + lightingAttenuation.w * color;\n" 369 " output.pixelColor0.a = materialDiffuse.a;\n" static std::string const msGLSLPSSource[2]
virtual void UpdateMaterialConstant()
std::shared_ptr< Material > mMaterial
std::shared_ptr< LightCameraGeometry > mGeometry
Vector4< float > cameraModelPosition
std::function< void(std::shared_ptr< Buffer > const &)> BufferUpdater
static std::string const msHLSLSource[2]
virtual void UpdateGeometryConstant()
static std::string const * msPSSource[2][ProgramFactory::PF_NUM_API]
std::shared_ptr< ConstantBuffer > mGeometryConstant
std::shared_ptr< Lighting > mLighting
virtual void UpdateGeometryConstant()
virtual void UpdateLightingConstant()
static std::string const msGLSLVSSource[2]
GLsizei const GLchar *const * string
std::shared_ptr< ConstantBuffer > mLightingConstant
static std::string GetShaderSourceLitFunctionGLSL()
Vector4< float > specular
Vector4< float > attenuation
std::shared_ptr< ConstantBuffer > mMaterialConstant
Vector4< float > specular
DirectionalLightEffect(std::shared_ptr< ProgramFactory > const &factory, BufferUpdater const &bufferUpdater, int select, std::shared_ptr< Material > const &material, std::shared_ptr< Lighting > const &lighting, std::shared_ptr< LightCameraGeometry > const &geometry)
virtual void UpdateMaterialConstant()
virtual void UpdateLightingConstant()
static std::string const * msVSSource[2][ProgramFactory::PF_NUM_API]
Vector4< float > emissive
std::shared_ptr< VisualProgram > mProgram
Vector4< float > lightModelDirection