mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0031279: Visualization, TKOpenGl - environment background is misplaced within Ray-Tracing
Fixed problem with misplacing background texture in Ray-Tracing. An environment background is always drawn using a perspective matrix.
This commit is contained in:
parent
4e8371cb1f
commit
832a6f4412
@ -2545,6 +2545,20 @@ Standard_Boolean OpenGl_View::setUniformState (const Standard_Integer the
|
|||||||
aDirects,
|
aDirects,
|
||||||
aViewPrjMat,
|
aViewPrjMat,
|
||||||
anUnviewMat);
|
anUnviewMat);
|
||||||
|
|
||||||
|
if (myRenderParams.UseEnvironmentMapBackground
|
||||||
|
|| myRaytraceParameters.CubemapForBack)
|
||||||
|
{
|
||||||
|
OpenGl_Mat4 aTempMat;
|
||||||
|
OpenGl_Mat4 aTempInvMat;
|
||||||
|
updatePerspCameraPT (myCamera->OrientationMatrixF(),
|
||||||
|
aCntxProjectionState.Current(),
|
||||||
|
theProjection,
|
||||||
|
aTempMat,
|
||||||
|
aTempInvMat,
|
||||||
|
theWinSizeX,
|
||||||
|
theWinSizeY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1023,6 +1023,7 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
|||||||
int aTrsfId;
|
int aTrsfId;
|
||||||
|
|
||||||
float aRaytraceDepth = MAXFLOAT;
|
float aRaytraceDepth = MAXFLOAT;
|
||||||
|
float aRefractionIdx = 0.0;
|
||||||
|
|
||||||
for (int aDepth = 0; aDepth < NB_BOUNCES; ++aDepth)
|
for (int aDepth = 0; aDepth < NB_BOUNCES; ++aDepth)
|
||||||
{
|
{
|
||||||
@ -1034,11 +1035,30 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
|||||||
{
|
{
|
||||||
vec4 aColor = vec4 (0.0);
|
vec4 aColor = vec4 (0.0);
|
||||||
|
|
||||||
if (bool(uEnvMapForBack) || aWeight.w == 0.0f /* reflection */)
|
if (bool(uEnvMapForBack) || aWeight.w == 0.0 /* reflection */)
|
||||||
{
|
{
|
||||||
float aTime = IntersectSphere (theRay, uSceneRadius);
|
float aRadius = uSceneRadius;
|
||||||
|
vec3 aTexCoord = vec3 (0.0);
|
||||||
|
|
||||||
aColor = FetchEnvironment (theRay.Direct * aTime + theRay.Origin, uSceneRadius, aWeight.w != 0.0);
|
if (aDepth == 0 || (aRefractionIdx == 1.0 && aWeight.w != 0.0))
|
||||||
|
{
|
||||||
|
vec2 aPixel = uEyeSize * (vPixel - vec2 (0.5)) * 2.0;
|
||||||
|
vec2 anAperturePnt = sampleUniformDisk() * uApertureRadius;
|
||||||
|
vec3 aLocalDir = normalize (vec3 (aPixel * uFocalPlaneDist - anAperturePnt, uFocalPlaneDist));
|
||||||
|
vec3 aDirect = uEyeView * aLocalDir.z +
|
||||||
|
uEyeSide * aLocalDir.x +
|
||||||
|
uEyeVert * aLocalDir.y;
|
||||||
|
|
||||||
|
aTexCoord = aDirect * uSceneRadius;
|
||||||
|
aRadius = length (aTexCoord);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float aTime = IntersectSphere (theRay, uSceneRadius);
|
||||||
|
aTexCoord = theRay.Direct * aTime + theRay.Origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
aColor = FetchEnvironment (aTexCoord, aRadius, aWeight.w != 0.0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1167,6 +1187,7 @@ vec4 Radiance (in SRay theRay, in vec3 theInverse)
|
|||||||
if (aOpacity.x != 1.0f)
|
if (aOpacity.x != 1.0f)
|
||||||
{
|
{
|
||||||
aWeight *= aOpacity.y;
|
aWeight *= aOpacity.y;
|
||||||
|
aRefractionIdx = aOpacity.z;
|
||||||
|
|
||||||
if (aOpacity.z != 1.0f)
|
if (aOpacity.z != 1.0f)
|
||||||
{
|
{
|
||||||
|
@ -1026,6 +1026,7 @@ static const char Shaders_RaytraceBase_fs[] =
|
|||||||
" int aTrsfId;\n"
|
" int aTrsfId;\n"
|
||||||
"\n"
|
"\n"
|
||||||
" float aRaytraceDepth = MAXFLOAT;\n"
|
" float aRaytraceDepth = MAXFLOAT;\n"
|
||||||
|
" float aRefractionIdx = 0.0;\n"
|
||||||
"\n"
|
"\n"
|
||||||
" for (int aDepth = 0; aDepth < NB_BOUNCES; ++aDepth)\n"
|
" for (int aDepth = 0; aDepth < NB_BOUNCES; ++aDepth)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
@ -1037,11 +1038,30 @@ static const char Shaders_RaytraceBase_fs[] =
|
|||||||
" {\n"
|
" {\n"
|
||||||
" vec4 aColor = vec4 (0.0);\n"
|
" vec4 aColor = vec4 (0.0);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" if (bool(uEnvMapForBack) || aWeight.w == 0.0f /* reflection */)\n"
|
" if (bool(uEnvMapForBack) || aWeight.w == 0.0 /* reflection */)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" float aTime = IntersectSphere (theRay, uSceneRadius);\n"
|
" float aRadius = uSceneRadius;\n"
|
||||||
|
" vec3 aTexCoord = vec3 (0.0);\n"
|
||||||
"\n"
|
"\n"
|
||||||
" aColor = FetchEnvironment (theRay.Direct * aTime + theRay.Origin, uSceneRadius, aWeight.w != 0.0);\n"
|
" if (aDepth == 0 || (aRefractionIdx == 1.0 && aWeight.w != 0.0))\n"
|
||||||
|
" {\n"
|
||||||
|
" vec2 aPixel = uEyeSize * (vPixel - vec2 (0.5)) * 2.0;\n"
|
||||||
|
" vec2 anAperturePnt = sampleUniformDisk() * uApertureRadius;\n"
|
||||||
|
" vec3 aLocalDir = normalize (vec3 (aPixel * uFocalPlaneDist - anAperturePnt, uFocalPlaneDist));\n"
|
||||||
|
" vec3 aDirect = uEyeView * aLocalDir.z +\n"
|
||||||
|
" uEyeSide * aLocalDir.x +\n"
|
||||||
|
" uEyeVert * aLocalDir.y;\n"
|
||||||
|
" \n"
|
||||||
|
" aTexCoord = aDirect * uSceneRadius;\n"
|
||||||
|
" aRadius = length (aTexCoord);\n"
|
||||||
|
" }\n"
|
||||||
|
" else\n"
|
||||||
|
" {\n"
|
||||||
|
" float aTime = IntersectSphere (theRay, uSceneRadius);\n"
|
||||||
|
" aTexCoord = theRay.Direct * aTime + theRay.Origin;\n"
|
||||||
|
" }\n"
|
||||||
|
"\n"
|
||||||
|
" aColor = FetchEnvironment (aTexCoord, aRadius, aWeight.w != 0.0);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
@ -1170,6 +1190,7 @@ static const char Shaders_RaytraceBase_fs[] =
|
|||||||
" if (aOpacity.x != 1.0f)\n"
|
" if (aOpacity.x != 1.0f)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" aWeight *= aOpacity.y;\n"
|
" aWeight *= aOpacity.y;\n"
|
||||||
|
" aRefractionIdx = aOpacity.z;\n"
|
||||||
"\n"
|
"\n"
|
||||||
" if (aOpacity.z != 1.0f)\n"
|
" if (aOpacity.z != 1.0f)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
|
18
tests/v3d/raytrace/bug31279
Normal file
18
tests/v3d/raytrace/bug31279
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "0031279: Visualization, TKOpenGl - environment background is misplaced within Ray-Tracing"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
source $env(CSF_OCCTSamplesPath)/tcl/raytrace.tcl
|
||||||
|
vrenderparams -env
|
||||||
|
vcamera -persp
|
||||||
|
vviewparams -scale 1.3 -proj 0.57 -0.57 0.57 -up -0.4 0.4 0.8 -at -62 -111 -15
|
||||||
|
vtextureenv on 1
|
||||||
|
|
||||||
|
if { [vreadpixel 100 100 rgb name] == "BLACK" } { puts "ERROR: background is misplaced" }
|
||||||
|
|
||||||
|
vcamera -persp
|
||||||
|
vdump $imagedir/${casename}_persp.png
|
||||||
|
|
||||||
|
vcamera -ortho
|
||||||
|
vdump $imagedir/${casename}_ortho.png
|
Loading…
x
Reference in New Issue
Block a user