当前位置: 首页>>代码示例>>Python>>正文


Python Shader.makeCompute方法代码示例

本文整理汇总了Python中panda3d.core.Shader.makeCompute方法的典型用法代码示例。如果您正苦于以下问题:Python Shader.makeCompute方法的具体用法?Python Shader.makeCompute怎么用?Python Shader.makeCompute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.Shader的用法示例。


在下文中一共展示了Shader.makeCompute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadCompute

# 需要导入模块: from panda3d.core import Shader [as 别名]
# 或者: from panda3d.core.Shader import makeCompute [as 别名]
    def loadCompute(self, source):
        """ Loads a compute shader """

        content = self._handleIncludes(source)
        result = Shader.makeCompute(Shader.SLGLSL, content)
        self._writeDebugShader("Compute-" + str(source), content)
        self._clearIncludeStack()
        return result
开发者ID:rasteron,项目名称:RenderPipeline,代码行数:10,代码来源:BetterShader.py

示例2: __Call

# 需要导入模块: from panda3d.core import Shader [as 别名]
# 或者: from panda3d.core.Shader import makeCompute [as 别名]
 def __Call(self, func_name, **kwargs):
     """Receive python call and redirect request to relevant
     function in image shader library; return modified image."""
     
     # Copy self.__Lines (need to keep orig for further calls) and
     # add "#define" statement to top to trigger compilation of
     # relevant "#ifdef/def" function block in shader.
     
     lines = list(self.__LINES)
     lines.insert(2, "#define {}".format(func_name))
     
     # Assemble lines into shader str and compile.
     shader_str = "".join(lines)
     self.__NP.setShader(Shader.makeCompute(Shader.SL_GLSL, shader_str))
     
     # Set block size from workgroup size.
     block_x = int(self.x_size/self.workgroup_size.x)
     block_y = int(self.y_size/self.workgroup_size.y)
     block_z = int(self.z_size/self.workgroup_size.z)
     block_size = LVector3i(block_x,block_y,block_z)
     
     # Create mod_tex for GPU.
     with TimeIt() as prep_timer:
         mod_img = PNMImage(self.x_size, self.y_size, 4)
         mod_tex = Texture()
         mod_tex.load(mod_img)
         mod_tex.setMinfilter(Texture.FTLinear)
         mod_tex.setFormat(self.img_format)
     self.prepare_time += prep_timer.total_time
     
     # Pass textures to shader.
     self.__NP.setShaderInput("ref_tex", self.__ref_tex)
     self.__NP.setShaderInput("mod_tex", mod_tex)
     
     # Set any additional required inputs for this function.
     for input_name, input_val in list(kwargs.items()):
         if type(input_val) == PNMImage:
             input_val = self.__get_Texture(input_val)
         self.__NP.setShaderInput(input_name, input_val)
     
     # Call function in shader library.
     shader_attrib = self.__NP.getAttrib(ShaderAttrib)
     with TimeIt() as proc_timer:
         base.graphicsEngine.dispatch_compute(block_size, shader_attrib, self.__gsg)
     self.process_time += proc_timer.total_time
     
     # Extract modified texture from GPU.
     with TimeIt() as extract_timer: 
         base.graphicsEngine.extractTextureData(mod_tex, self.__gsg)
     self.extract_time += extract_timer.total_time
     return mod_tex
开发者ID:svfgit,项目名称:solex,代码行数:53,代码来源:panda3d_gpu.py

示例3: _createClearShader

# 需要导入模块: from panda3d.core import Shader [as 别名]
# 或者: from panda3d.core.Shader import makeCompute [as 别名]
    def _createClearShader(self):
        """ Internal method to create the compute shader which will
        clear the texture """

        shader = """
        #version 150
        #extension GL_ARB_compute_shader : enable
        #extension GL_ARB_shader_image_load_store : enable

        layout (local_size_x = 16, local_size_y = 16) in;

        uniform int layers;
        uniform writeonly image2D destination;
        uniform vec4 clearColor;
        
        void main() {
            ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
            imageStore(destination, coord, clearColor);
        }
        """
        return Shader.makeCompute(Shader.SLGLSL, shader)
开发者ID:Happy-Ferret,项目名称:RenderPipeline,代码行数:23,代码来源:TextureCleaner.py


注:本文中的panda3d.core.Shader.makeCompute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。