Method, apparatus, electronic device and storage medium for controlling based on extended reality
View Patent ↗This disclosure provides a method, apparatus, electronic device, and storage medium for controlling based on extended reality. In some embodiments, this disclosure provides a method of controlling based on extended reality, including: displaying a virtual environment and a virtual screen located in the virtual environment in an extended reality space; and in response to displaying a played content on the virtual screen, rendering a light of the played content into a rendering region of the virtual environment to present a reflection of the played content in the rendering region of the virtual environment.
1 . A method of controlling based on extended reality, comprising:
displaying a virtual environment and a virtual screen located in the virtual environment in an extended reality space; and
in response to displaying a played content on the virtual screen, rendering a light of a current content frame of the played content into a rendering region of the virtual environment to present a diffuse reflection of the current content frame of the played content in the rendering region of the virtual environment,
wherein rendering the light of the current content frame of the played content into the rendering region of the virtual environment comprises:
obtaining the current content frame of the played content;
determining a content region corresponding to the rendering region in the virtual environment based on the current content frame and a position of the rendering region in the virtual environment; and
rendering a color of the content region to the corresponding rendering region in the virtual environment;
wherein rendering the color of the content region to the corresponding rendering region in the virtual environment comprises:
generating a copied image of the content region,
stretching the copied image to have a same size as the rendering region, and
covering the copied image onto the rendering region;
wherein determining the content region corresponding to the rendering region in the virtual environment based on the current content frame and the position of the rendering region in the virtual environment comprises:
determining an edge of the virtual screen near the rendering region in the virtual environment; and
cropping an edge region of the edge in the current content frame as the corresponding content region.
2 . The method of claim 1 , before rendering the color of the content region to the corresponding rendering region in the virtual environment, further comprising:
generating a noise map, so that coordinates of at least part of pixels in the target-content region are produced offsets through the noise map.
3 . The method of claim 1 , wherein rendering the color of the content region to the corresponding rendering region in the virtual environment comprises:
determining a fusion coefficient;
determining a weight of the color of the content region and an own color of the corresponding rendering region in the virtual environment based on the fusion coefficient; and
fusing the color of the content region with the own color of the corresponding rendering region in the virtual environment in accordance with respective weights to obtain a color displayed in the rendering region in the virtual environment.
4 . The method of claim 1 , before rendering the color of the content region to the corresponding rendering region in the virtual environment, further comprising:
setting, in different directions, a region size of a rendering region able to reflect the played content in the virtual environment.
5 . The method of claim 4 , wherein,
the rendering region is trapezoid with a length of an upper bottom equal to a length of an edge of the played content in a direction of the rendering region.
6 . The method of claim 1 , wherein,
rendering the color of the content region to the corresponding rendering region in the virtual environment comprises: simulating a diffuse reflection light of the light of the content region illuminating the corresponding rendering region based on an angle between the virtual screen and the rendering region and the content region, and displaying the diffuse reflection light in the rendering region.
7 . The method of claim 1 , further comprising:
performing processing of blurring edges of the light of the played content rendered into the virtual environment; and/or,
controlling an intensity of the light of the played content rendered into the virtual environment to decrease as the distance from the virtual screen increases based on a predetermined attenuation coefficient.
8 . The method of claim 1 , further comprising:
if a shadow region blocked by an object exists in the rendering region of the virtual environment, performing processing of fading the light of the played content projected into the shadow region.
9 . An electronic device, comprising:
at least one memory and at least one processor;
wherein the at least one memory is configured to store program code, and the at least one processor is configured to call the program code stored in the at least one memory to perform acts comprising:
displaying a virtual environment and a virtual screen located in the virtual environment in an extended reality space; and
in response to displaying a played content on the virtual screen, rendering a light of a current content frame of the played content into a rendering region of the virtual environment to present a diffuse reflection of the current content frame of the played content in the rendering region of the virtual environment,
wherein rendering the light of the current content frame of the played content into the rendering region of the virtual environment comprises:
obtaining the current content frame of the played content;
determining a content region corresponding to the rendering region in the virtual environment based on the current content frame and a position of the rendering region in the virtual environment; and
rendering a color of the content region to the corresponding rendering region in the virtual environment:
wherein rendering the color of the content region to the corresponding rendering region in the virtual environment comprises:
generating a copied image of the content region,
stretching the copied image to have a same size as the rendering region, and
covering the copied image onto the rendering region;
wherein determining the content region corresponding to the rendering region in the virtual environment based on the current content frame and the position of the rendering region in the virtual environment comprises:
determining an edge of the virtual screen near the rendering region in the virtual environment; and
cropping an edge region of the edge in the current content frame as the corresponding content region.
10 . The device of claim 9 , the acts further comprising:
before rendering the color of the content region to the corresponding rendering region in the virtual environment, generating a noise map, so that coordinates of at least part of pixels in the content region are produced offsets through the noise map.
11 . The device of claim 9 , wherein rendering the color of the content region to the corresponding rendering region in the virtual environment comprises:
determining a fusion coefficient;
determining a weight of the color of the content region and an own color of the corresponding rendering region in the virtual environment based on the fusion coefficient; and
fusing the color of the content region with the own color of the corresponding rendering region in the virtual environment in accordance with respective weights to obtain a color displayed in the rendering region in the virtual environment.
12 . The device of claim 9 , the acts further comprising:
before rendering the color of the content region to the corresponding rendering region in the virtual environment, setting, in different directions, a region size of a rendering region able to reflect the played content in the virtual environment.
13 . The device of claim 9 , wherein,
rendering the color of the content region to the corresponding rendering region in the virtual environment comprises: simulating a diffuse reflection light of the light of the content region illuminating the corresponding rendering region based on an angle between the virtual screen and the rendering region and the content region, and displaying the diffuse reflection light in the rendering region.
14 . The device of claim 9 , the acts further comprising:
performing processing of blurring edges of the light of the played content rendered into the virtual environment; and/or,
controlling an intensity of the light of the played content rendered into the virtual environment to decrease as the distance from the virtual screen increases based on a predetermined attenuation coefficient.
15 . The device of claim 9 , the acts further comprising:
if a shadow region blocked by an object exists in the rendering region of the virtual environment, performing processing of fading the light of the played content projected into the shadow region.
16 . A non-transitory computer readable storage medium for storing program code that, when executed by a processor, causing the processor to perform a method, comprising:
displaying a virtual environment and a virtual screen located in the virtual environment in an extended reality space; and
in response to displaying a played content on the virtual screen, rendering a light of a current content frame of the played content into a rendering region of the virtual environment to present a diffuse reflection of the current content frame of the played content in the rendering region of the virtual environment,
wherein rendering the light of the current content frame of the played content into the rendering region of the virtual environment comprises:
obtaining the current content frame of the played content;
determining a content region corresponding to the rendering region in the virtual environment based on the current content frame and a position of the rendering region in the virtual environment; and
rendering a color of the content region to the corresponding rendering region in the virtual environment;
wherein rendering the color of the content region to the corresponding rendering region in the virtual environment comprises:
generating a copied image of the content region,
stretching the copied image to have a same size as the rendering region, and
covering the copied image onto the rendering region;
wherein determining the content region corresponding to the rendering region in the virtual environment based on the current content frame and the position of the rendering region in the virtual environment comprises:
determining an edge of the virtual screen near the rendering region in the virtual environment; and
cropping an edge region of the edge in the current content frame as the corresponding content region.