diff --git a/src/Shaders/PhongShading.fs b/src/Shaders/PhongShading.fs index 30ccaa6d59..bdcd58c62b 100755 --- a/src/Shaders/PhongShading.fs +++ b/src/Shaders/PhongShading.fs @@ -165,9 +165,11 @@ vec4 computeLighting (in vec3 theNormal, vec4 aMaterialAmbient = gl_FrontFacing ? occFrontMaterial_Ambient() : occBackMaterial_Ambient(); vec4 aMaterialDiffuse = gl_FrontFacing ? occFrontMaterial_Diffuse() : occBackMaterial_Diffuse(); vec4 aMaterialSpecular = gl_FrontFacing ? occFrontMaterial_Specular() : occBackMaterial_Specular(); + vec4 aMaterialEmission = gl_FrontFacing ? occFrontMaterial_Emission() : occBackMaterial_Emission(); return vec4 (Ambient, 1.0) * aMaterialAmbient + vec4 (Diffuse, 1.0) * aMaterialDiffuse - + vec4 (Specular, 1.0) * aMaterialSpecular; + + vec4 (Specular, 1.0) * aMaterialSpecular + + aMaterialEmission; } //! Entry point to the Fragment Shader diff --git a/src/Shaders/RaytraceBase.fs b/src/Shaders/RaytraceBase.fs index ce6c1bc94c..1b860c30c6 100644 --- a/src/Shaders/RaytraceBase.fs +++ b/src/Shaders/RaytraceBase.fs @@ -916,7 +916,9 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse) uRaytraceMaterialTexture, MATERIAL_SPEC (aTriIndex.w)); vec4 aOpacity = texelFetch ( uRaytraceMaterialTexture, MATERIAL_TRAN (aTriIndex.w)); - + vec3 aEmission = texelFetch ( + uRaytraceMaterialTexture, MATERIAL_EMIS (aTriIndex.w)).rgb; + vec3 aNormal = SmoothNormal (aHit.UV, aTriIndex); vec4 aInvTransf0 = texelFetch (uSceneTransformTexture, anObjectId * 4 + 0); @@ -980,6 +982,8 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse) aResult.xyz += aWeight.xyz * uGlobalAmbient.xyz * aAmbient * aOpacity.x * max (abs (dot (aNormal, theRay.Direct)), 0.5f); + + aResult.xyz += aWeight.xyz * aOpacity.x * aEmission; if (aOpacity.x != 1.0f) { diff --git a/tests/v3d/materials/bug24872_1 b/tests/v3d/materials/bug24872_1 new file mode 100644 index 0000000000..20ce1d01aa --- /dev/null +++ b/tests/v3d/materials/bug24872_1 @@ -0,0 +1,10 @@ +puts "=========" +puts "OCC24872" +puts "=========" +puts "" +########################################################### +# Support of emission color in Phong shader and ray-tracing +########################################################### + +source $env(CASROOT)/samples/tcl/materials.tcl +vshaderprog phong diff --git a/tests/v3d/materials/bug24872_2 b/tests/v3d/materials/bug24872_2 new file mode 100644 index 0000000000..26ccadd600 --- /dev/null +++ b/tests/v3d/materials/bug24872_2 @@ -0,0 +1,10 @@ +puts "=========" +puts "OCC24872" +puts "=========" +puts "" +########################################################### +# Support of emission color in Phong shader and ray-tracing +########################################################### + +source $env(CASROOT)/samples/tcl/materials.tcl +vrenderparams -raytrace