def __init__(self, parent=None, x=0, y=0, callback=None, extraArgs=None, radio=False, expandW=100, checked=False):
        DebugObject.__init__(self, "BCheckbox")

        prefix = "Checkbox" if not radio else "Radiobox"

        checkedImg = Globals.loader.loadTexture("Data/GUI/" + prefix + "Active.png")
        uncheckedImg = Globals.loader.loadTexture("Data/GUI/" + prefix + "Empty.png")

        for tex in [checkedImg, uncheckedImg]:
            tex.setMinfilter(Texture.FTNearest)
            tex.setMagfilter(Texture.FTNearest)
            tex.setAnisotropicDegree(0)
            tex.setWrapU(Texture.WMClamp)
            tex.setWrapV(Texture.WMClamp)

        self._node = DirectCheckBox(parent=parent, pos=(
            x + 7.5, 1, -y - 7.5), scale=(15 / 2.0, 1, 15 / 2.0), checkedImage=checkedImg, uncheckedImage=uncheckedImg,
            image=uncheckedImg, extraArgs = extraArgs, state=DGG.NORMAL,
            relief=DGG.FLAT, command=self._updateStatus)

        self._node["frameColor"] = (0, 0, 0, 0.0)
        self._node["frameSize"] = (-2, 2 + expandW / 7.5, -1.6, 1.6)

        self._node.setTransparency(TransparencyAttrib.MAlpha)

        self.callback = callback
        self.extraArgs = extraArgs
        self.collection = None

        if checked:
            self._setChecked(True)
Exemplo n.º 2
0
 def __init__(self, showbase):
     """ Creates a new pipeline """
     DebugObject.__init__(self, "RenderingPipeline")
     self.showbase = showbase
     self.settings = None
     self.ready = False
     self.mountManager = MountManager()
Exemplo n.º 3
0
    def __init__(self, name="DefaultRT"):
        """ Creates a new RenderTarget with the given name. Use a
        descriptive name as it will show with this name in pstats """
        DebugObject.__init__(self, "RenderTarget")
        self._targetFlags = {}
        self._bindMode = GraphicsOutput.RTMBindOrCopy
        self._depthbits = 8
        self._buffer = None
        self._quad = None
        self._sourceCam = Globals.base.cam
        self._sourceWindow = Globals.base.win
        self._width = -1
        self._height = -1
        self._name = name
        self._colorBits = 8
        self._auxBits = 8
        self._region = self._findRegionForCamera()
        self._enableTransparency = False
        self._layers = 0
        self._writeColor = True
        self._multisamples = 0
        self._engine = Globals.base.graphicsEngine
        self._rename(name)

        self.mute()
Exemplo n.º 4
0
    def loadSettings(self, filename):
        """ Loads the pipeline settings from an ini file """
        self.settings = PipelineSettingsManager()
        self.settings.loadFromFile(filename)

        # This has to be here, before anything is printed
        DebugObject.setOutputLevel(self.settings.pipelineOutputLevel)
Exemplo n.º 5
0
    def __init__(self, timeOfDay):
        QtGui.QMainWindow.__init__(self)
        DebugObject.__init__(self, "TimeOfDayEditor")
        self.setupUi(self)

        self.sliders = [
            self.slider00,
            self.slider03,
            self.slider06,
            self.slider09,
            self.slider12,
            self.slider15,
            self.slider18,
            self.slider21,
        ]

        for slider in self.sliders:
            slider.valueChanged.connect(self.sliderChanged)

        self.btnReset.clicked.connect(self.resetProperty)
        self.btnSmooth.clicked.connect(self.smoothProperty)
        self.btnSave.clicked.connect(self.save)
        self.btnGenerateClasses.clicked.connect(self.generateClasses)
        self.currentProperty = None
        self.widget = CurveWidget(self.curveBG)
        self.propertyList.selectionModel().selectionChanged.connect(
            self.selectedProperty)
        self.timeOfDay = timeOfDay
        self.fillList()
        self.savePath = None
        self.autoClassPath = None
        self.shaderIncludePath = None

        self.haveUnsavedChanges = False
        self.applicationMovedSlider = False
Exemplo n.º 6
0
    def __init__(self):
        """ Constructs a new Light, subclasses have to call this """
        DebugObject.__init__(self, "AbstractLight")
        ShaderStructElement.__init__(self)
        self.debugNode = NodePath("LightDebug")
        self.visualizationNumSteps = 32
        self.dataNeedsUpdate = False
        self.castShadows = False
        self.debugEnabled = False
        self.bounds = OmniBoundingVolume()
        self.shadowSources = []
        self.lightType = self.getLightType()
        self.position = Vec3(0)
        self.color = Vec3(1)
        self.posterIndex = -1
        self.radius = 10.0
        self.typeName = ""
        self.sourceIndexes = PTAInt.emptyArray(6)
        self.attached = False
        self.shadowResolution = 512
        self.index = -1
        self.iesProfile = -1
        self.iesProfileName = None
        self.mvp = Mat4()

        # A light can have up to 6 sources
        for i in range(6):
            self.sourceIndexes[i] = -1
 def __init__(self, showbase):
     """ Creates a new pipeline """
     DebugObject.__init__(self, "RenderingPipeline")
     self.showbase = showbase
     self.settings = None
     self.ready = False
     self.mountManager = MountManager()
Exemplo n.º 8
0
 def __init__(self, techniqueName):
     """ Subclasses have to call this. techniqueName should be
     something like "SMAA" """
     DebugObject.__init__(self, "Antialiasing-" + techniqueName)
     self._colorTexture = None
     self._depthTexture = None
     self._velocityTexture = None
Exemplo n.º 9
0
    def __init__(self, timeOfDay):
        QtGui.QMainWindow.__init__(self)
        DebugObject.__init__(self, "TimeOfDayEditor")
        self.setupUi(self)

        self.sliders = [
            self.slider00,
            self.slider03,
            self.slider06,
            self.slider09,
            self.slider12,
            self.slider15,
            self.slider18,
            self.slider21,
        ]

        for slider in self.sliders:
            slider.valueChanged.connect(self.sliderChanged)

        self.btnReset.clicked.connect(self.resetProperty)
        self.btnSmooth.clicked.connect(self.smoothProperty)
        self.btnSave.clicked.connect(self.save)
        self.btnGenerateClasses.clicked.connect(self.generateClasses)
        self.currentProperty = None
        self.widget = CurveWidget(self.curveBG)
        self.propertyList.selectionModel().selectionChanged.connect(
            self.selectedProperty)
        self.timeOfDay = timeOfDay
        self.fillList()
        self.savePath = None
        self.autoClassPath = None
        self.shaderIncludePath = None

        self.haveUnsavedChanges = False
        self.applicationMovedSlider = False
Exemplo n.º 10
0
    def __init__(self, pipeline):
        DebugObject.__init__(self, "GlobalIllumnination")
        self.pipeline = pipeline

        # Fetch the scene data
        self.targetCamera = Globals.base.cam
        self.targetSpace = Globals.base.render

        # Store grid size in world space units
        # This is the half voxel grid size
        self.voxelGridSizeWS = Vec3(60)

        # When you change this resolution, you have to change it in Shader/GI/ConvertGrid.fragment aswell
        self.voxelGridResolution = LVecBase3i(256)

        self.targetLight = None
        self.helperLight = None
        self.ptaGridPos = PTALVecBase3f.emptyArray(1)
        self.gridPos = Vec3(0)

        # Create ptas 

        self.ptaLightUVStart = PTALVecBase2f.emptyArray(1)
        self.ptaLightMVP = PTAMat4.emptyArray(1)
        self.ptaVoxelGridStart = PTALVecBase3f.emptyArray(1)
        self.ptaVoxelGridEnd = PTALVecBase3f.emptyArray(1)
        self.ptaLightDirection = PTALVecBase3f.emptyArray(1)

        self.targetSpace.setShaderInput("giLightUVStart", self.ptaLightUVStart)
        self.targetSpace.setShaderInput("giLightMVP", self.ptaLightMVP)
        self.targetSpace.setShaderInput("giVoxelGridStart", self.ptaVoxelGridStart)
        self.targetSpace.setShaderInput("giVoxelGridEnd", self.ptaVoxelGridEnd)
        self.targetSpace.setShaderInput("giLightDirection", self.ptaLightDirection)
Exemplo n.º 11
0
    def __init__(self, pipeline):
        """ Creates a new Scattering object with default settings """
        DebugObject.__init__(self, "AtmosphericScattering")

        self.pipeline = pipeline
        self.settings = {
            "radiusGround": 6360.0,
            "radiusAtmosphere": 6420.0,
            "averageGroundReflectance": 0.1, 
            "rayleighFactor": 8.0,
            "betaRayleigh": Vec3(5.8e-3, 1.35e-2, 3.31e-2),
            "mieFactor": 1.2,
            "betaMieScattering": Vec3(4e-3),
            "betaMieScatteringAdjusted": (Vec3(2e-3) * (1.0 / 0.9)),
            "mieG": 0.8,
            "transmittanceNonLinear": True,
            "inscatterNonLinear": True,
            "atmosphereOffset": Vec3(0),
            "atmosphereScale": Vec3(1),
            "sunVector": Vec3(0,1,0)
        }

        # Store all parameters in a pta, that is faster than using setShaderInput
        self.settingsPTA = {}
        self.targets = {}
        self.textures = {}
        self.precomputed = False
        self.sunLight = None

        self.inscatterResult = None
        self.transmittanceResult = None
Exemplo n.º 12
0
    def __init__(self):
        """ Constructs a new Light, subclasses have to call this """
        DebugObject.__init__(self, "AbstractLight")
        ShaderStructElement.__init__(self)
        self.debugNode = NodePath("LightDebug")
        self.visualizationNumSteps = 32
        self.dataNeedsUpdate = False
        self.castShadows = False
        self.debugEnabled = False
        self.bounds = OmniBoundingVolume()
        self.shadowSources = []
        self.lightType = self.getLightType()
        self.position = Vec3(0)
        self.color = Vec3(1)
        self.posterIndex = -1
        self.direction = Vec3(0)
        self.radius = 10.0
        self.typeName = ""
        self.sourceIndexes = PTAInt.emptyArray(6)
        self.attached = False
        self.shadowResolution = 512
        self.index = -1
        self.iesProfile = -1
        self.iesProfileName = None
        self.mvp = Mat4()

        # A light can have up to 6 sources
        for i in range(6):
            self.sourceIndexes[i] = -1
Exemplo n.º 13
0
    def __init__(self):
        """ Creates a new ShadowSource. After the creation, a lens can be added
        with setupPerspectiveLens or setupOrtographicLens. """
        self.index = self._generateUID()
        DebugObject.__init__(self, "ShadowSource-" + str(self.index))
        ShaderStructElement.__init__(self)

        self.valid = False
        self.camera = Camera("ShadowSource-" + str(self.index))
        self.camera.setActive(False)
        self.cameraNode = NodePath(self.camera)
        self.cameraNode.reparentTo(Globals.render.find("RPCameraDummys"))
        self.cameraNode.hide()
        self.resolution = 512
        self.atlasPos = Vec2(0)
        self.doesHaveAtlasPos = False
        self.sourceIndex = 0
        self.mvp = UnalignedLMatrix4f()
        self.sourceIndex = -1
        self.nearPlane = 0.0
        self.farPlane = 1000.0
        self.converterYUR = None
        self.transforMat = TransformState.makeMat(
            Mat4.convertMat(Globals.base.win.getGsg().getInternalCoordinateSystem(),
                            CSZupRight))
Exemplo n.º 14
0
    def __init__(self):
        """ Creates a new ShadowSource. After the creation, a lens can be added
        with setupPerspectiveLens or setupOrtographicLens. """
        self.index = self._generateUID()
        DebugObject.__init__(self, "ShadowSource-" + str(self.index))
        ShaderStructElement.__init__(self)

        self.valid = False
        self.camera = Camera("ShadowSource-" + str(self.index))
        self.camera.setActive(False)
        self.cameraNode = NodePath(self.camera)
        self.cameraNode.reparentTo(Globals.render.find("RPCameraDummys"))
        self.cameraNode.hide()
        self.resolution = 512
        self.atlasPos = Vec2(0)
        self.doesHaveAtlasPos = False
        self.sourceIndex = 0
        self.mvp = UnalignedLMatrix4f()
        self.sourceIndex = -1
        self.nearPlane = 0.0
        self.farPlane = 1000.0
        self.converterYUR = None
        self.transforMat = TransformState.makeMat(
            Mat4.convertMat(
                Globals.base.win.getGsg().getInternalCoordinateSystem(),
                CSZupRight))
Exemplo n.º 15
0
 def __init__(self, name="DefaultRT"):
     """ Creates a new RenderTarget with the given name. Use a
     descriptive name as it will show with this name in pstats """
     DebugObject.__init__(self, "RenderTarget")
     self._targets = {}
     self._bindMode = GraphicsOutput.RTMBindOrCopy
     self._depthBits = 8
     self._quad = None
     self._sourceCam = Globals.base.cam
     self._sourceWindow = Globals.base.win
     self._width = -1
     self._height = -1
     self._name = name
     self._colorBits = 8
     self._auxBits = 8
     self._region = self._findRegionForCamera()
     self._enableTransparency = False
     self._layers = 0
     self._createOverlayQuad = True
     self._writeColor = True
     self._multisamples = 0
     self._engine = Globals.base.graphicsEngine
     self._active = False
     self._useTextureArrays = False
     self._haveColorAlpha = True
     self._internalBuffer = None
     self._camera = None
     self._node = None
     self._rename(name)
     self.mute()
Exemplo n.º 16
0
    def loadSettings(self, filename):
        """ Loads the pipeline settings from an ini file """
        self.settings = PipelineSettingsManager()
        self.settings.loadFromFile(filename)

        # This has to be here, before anything is printed
        DebugObject.setOutputLevel(self.settings.pipelineOutputLevel)
 def __init__(self, pipeline):
     """ Creates the manager and creates the vertex buffer"""
     DebugObject.__init__(self, "DynamicObjectsManager")
     self.pipeline = pipeline
     self.currentIndex = 0
     self.maxVertexCount = 5000000
     self.split = 500
     self.init()
Exemplo n.º 18
0
 def __init__(self):
     """ Creates a new point light. Remember to set a position
     and a radius """
     Light.__init__(self)
     DebugObject.__init__(self, "PointLight")
     self.spacing = 0.5
     self.bufferRadius = 0.0
     self.typeName = "PointLight"
Exemplo n.º 19
0
 def __init__(self):
     """ Creates a new render pass manager. There should only be 1 instance
     at a time """
     DebugObject.__init__(self, "RenderPassManager")
     self.renderPasses = {}
     self.staticVariables = {}
     self.dynamicVariables = {}
     self.defines = {}
Exemplo n.º 20
0
 def __init__(self):
     """ Creates a new render pass manager. There should only be 1 instance
     at a time """
     DebugObject.__init__(self, "RenderPassManager")
     self.renderPasses = {}
     self.staticVariables = {}
     self.dynamicVariables = {}
     self.defines = {}
Exemplo n.º 21
0
 def __init__(self, pipeline):
     """ Creates the manager and creates the vertex buffer"""
     DebugObject.__init__(self, "DynamicObjectsManager")
     self.pipeline = pipeline
     self.currentIndex = 0
     self.maxVertexCount = 500000
     self.split = int(math.sqrt(self.maxVertexCount))
     self.init()
    def __init__(self, pipeline):
        DebugObject.__init__(self, "GUIManager")
        self.pipeline = pipeline
        self.body = Globals.base.pixel2d
        self.showbase = pipeline.showbase
        self.guiActive = False

        self.defines = {}
Exemplo n.º 23
0
 def __init__(self):
     """ Creates a new point light. Remember to set a position
     and a radius """
     Light.__init__(self)
     DebugObject.__init__(self, "PointLight")
     self.spacing = 0.5
     self.bufferRadius = 0.0
     self.typeName = "PointLight"
    def __init__(self):
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")

        self._spacing = 0.6
        self.radius = 99999999999.0
        self.position = Vec3(0)
        self.bounds = OmniBoundingVolume()
Exemplo n.º 25
0
    def __init__(self, classType, arraySize):
        """ Constructs a new array, containing elements of classType and
        with the size of numElements. classType and arraySize can't be
        changed after initialization """

        DebugObject.__init__(self, "ShaderStructArray")

        self.arrayIndex = len(self.AllArrays)
        self.AllArrays.append(self)


        self.classType = classType
        self.attributes = classType.getExposedAttributes()

        self.size = arraySize
        self.parents = {}
        self.ptaWrappers = {}
        self.assignedObjects = [None for i in range(arraySize)]

        componentSize = 0

        for name, attrType in self.attributes.iteritems():
            arrayType = PTAFloat
            numElements = 1
            numFloats = 1

            if attrType == "mat4":
                arrayType = PTAMat4
                numFloats = 16

            elif attrType == "int":
                arrayType = PTAInt
                numFloats = 1

            # hacky, but works, will get replaced later by a parser
            elif attrType == "array<int>(6)":
                arrayType = PTAInt
                numElements = 6
                numFloats = 6

            elif attrType == "float":
                arrayType = PTAFloat
                numFloats = 1

            elif attrType == "vec2":
                arrayType = PTALVecBase2f
                numFloats = 2

            elif attrType == "vec3":
                arrayType = PTALVecBase3f
                numFloats = 3

            componentSize += numFloats
            self.ptaWrappers[name] = [
                arrayType.emptyArray(numElements) for i in range(self.size)]

        self.debug("Init array, size =", self.size,"floats=",componentSize,"total =",self.size * componentSize)
Exemplo n.º 26
0
    def __init__(self, name):
        """ Creates a new settings manager. Subclasses should implement
        _addDefaultSettings to populate the settings. Otherwise this class
        won't be able to read the options. With loadFromFile a ini file is
        read, and the settings are filled with values from it. """

        DebugObject.__init__(self, name)
        self.settings = {}
        self._addDefaultSettings()
Exemplo n.º 27
0
 def __init__(self):
     """ Constructs a new directional light. You have to set a
     direction for this light to work properly"""
     Light.__init__(self)
     DebugObject.__init__(self, "GIHelperLight")
     self.typeName = "GIHelperLight"
     self.targetLight = None
     self.filmSize = 50
     self.bounds = OmniBoundingVolume()
Exemplo n.º 28
0
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Exemplo n.º 29
0
 def __init__(self, pipeline):
     """ Creates the manager and directly setups the passes """
     DebugObject.__init__(self, "AntialiasingManager")
     self.pipeline = pipeline
     self.jitter = False
     self.jitterOffsets = []
     self.jitterIndex = 0
     self.jitterPTA = PTAVecBase2f.emptyArray(1)
     self.create()
Exemplo n.º 30
0
    def __init__(self, name):
        """ Creates a new settings manager. Subclasses should implement
        _addDefaultSettings to populate the settings. Otherwise this class
        won't be able to read the options. With loadFromFile a ini file is
        read, and the settings are filled with values from it. """

        DebugObject.__init__(self, name)
        self.settings = {}
        self._addDefaultSettings()
Exemplo n.º 31
0
 def __init__(self, pipeline):
     """ Creates the manager and directly setups the passes """
     DebugObject.__init__(self, "AntialiasingManager")
     self.pipeline = pipeline
     self.jitter = False
     self.jitterOffsets = []
     self.jitterIndex = 0
     self.jitterPTA = PTAVecBase2f.emptyArray(1)
     self.create()
Exemplo n.º 32
0
    def __init__(self):
        """ Creates a new mount manager """
        DebugObject.__init__(self, "MountManager")
        self.writePath = "Temp/"
        self.basePath = "."
        self.lockFile = "Temp/instance.pid"
        self.modelPaths = []

        atexit.register(self.cleanup)
Exemplo n.º 33
0
    def __init__(self, classType, arraySize):
        """ Constructs a new array, containing elements of classType and
        with the size of numElements. classType and arraySize can't be
        changed after initialization """

        DebugObject.__init__(self, "ShaderStructArray")

        self.arrayIndex = len(self.AllArrays)
        self.AllArrays.append(self)


        self.classType = classType
        self.attributes = classType.getExposedAttributes()

        self.size = arraySize
        self.parents = {}
        self.ptaWrappers = {}
        self.assignedObjects = [None for i in range(arraySize)]

        componentSize = 0

        for name, attrType in self.attributes.iteritems():
            arrayType = PTAFloat
            numElements = 1
            numFloats = 1

            if attrType == "mat4":
                arrayType = PTAMat4
                numFloats = 16

            elif attrType == "int":
                arrayType = PTAInt
                numFloats = 1

            # hacky, but works, will get replaced later by a parser
            elif attrType == "array<int>(6)":
                arrayType = PTAInt
                numElements = 6
                numFloats = 6

            elif attrType == "float":
                arrayType = PTAFloat
                numFloats = 1

            elif attrType == "vec2":
                arrayType = PTALVecBase2f
                numFloats = 2

            elif attrType == "vec3":
                arrayType = PTALVecBase3f
                numFloats = 3

            componentSize += numFloats
            self.ptaWrappers[name] = [
                arrayType.emptyArray(numElements) for i in range(self.size)]

        self.debug("Init array, size =", self.size,"floats=",componentSize,"total =",self.size * componentSize)
Exemplo n.º 34
0
    def __init__(self):
        """ Creates a new IES Loader """
        DebugObject.__init__(self, "IESLoader")
        self.storage = Texture("IESProfiles")
        self.storage.setup2dTextureArray(self.IESTableResolution, 1, 64, Texture.TFloat, Texture.FRgba16)
        self.storage.setMinfilter(SamplerState.FTLinear)
        self.storage.setMagfilter(SamplerState.FTLinear)
        self.storage.setWrapU(SamplerState.WMClamp)
        self.storage.setWrapV(SamplerState.WMClamp)
        self.storage.setWrapW(SamplerState.WMClamp)

        self.profileNames = []
Exemplo n.º 35
0
    def __init__(self, pipeline):
        """ Creates the manager, but does not init the buffers """
        DebugObject.__init__(self, "TransparencyManager")
        self.debug("Initializing ..")

        self.pipeline = pipeline

        # This stores the maximum amount of transparent pixels which can be on the
        # screen at one time. If the amount of pixels exceeds this value, strong
        # artifacts will occur!
        self.maxPixelCount = 1920 * 1080 * 2
        self.initTransparencyPass()
Exemplo n.º 36
0
    def __init__(self, pipeline):
        """ Creates the manager, but does not init the buffers """
        DebugObject.__init__(self, "TransparencyManager")
        self.debug("Initializing ..")

        self.pipeline = pipeline

        # This stores the maximum amount of transparent pixels which can be on the
        # screen at one time. If the amount of pixels exceeds this value, strong
        # artifacts will occur!
        self.maxPixelCount = 1920 * 1080 / 2
        self.initTransparencyPass()
Exemplo n.º 37
0
    def __init__(self):
        """ Creates a new IES Loader """
        DebugObject.__init__(self, "IESLoader")
        self.storage = Texture("IESProfiles")
        self.storage.setup2dTextureArray(self.IESTableResolution, 1, 64,
                                         Texture.TFloat, Texture.FRgba16)
        self.storage.setMinfilter(SamplerState.FTLinear)
        self.storage.setMagfilter(SamplerState.FTLinear)
        self.storage.setWrapU(SamplerState.WMClamp)
        self.storage.setWrapV(SamplerState.WMClamp)
        self.storage.setWrapW(SamplerState.WMClamp)

        self.profileNames = []
Exemplo n.º 38
0
    def __init__(self, pipeline):
        DebugObject.__init__(self, "GlobalIllumnination")
        self.pipeline = pipeline

        self.targetCamera = Globals.base.cam
        self.targetSpace = Globals.base.render

        self.voxelBaseResolution = 512 * 4
        self.voxelGridSizeWS = Vec3(50, 50, 20)
        self.voxelGridResolution = LVecBase3i(512, 512, 128)
        self.targetLight = None
        self.helperLight = None
        self.ptaGridPos = PTALVecBase3f.emptyArray(1)
        self.gridPos = Vec3(0)
Exemplo n.º 39
0
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"
        self.splitCount = 4
        self.pssmTargetCam = None
        self.pssmTargetLens = None
        self.pssmFarPlane = 100.0
        self.pssmSplitPow = 2.0
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Exemplo n.º 40
0
    def __init__(self, name="RB"):
        DebugObject.__init__(self, "RenderBuffer")
        self._name = name
        self._width = 0
        self._height = 0
        self._colorBits = 8
        self._auxBits = 8
        self._bindMode = GraphicsOutput.RTMBindOrCopy
        self._depthBits = 24

        self._internalBuffer = None
        self._targets = {}
        self._win = None
        self._layers = 0

        self.mute()
Exemplo n.º 41
0
    def __init__(self):
        DebugObject.__init__(self, "Effect")

        Effect.effectCount += 1

        self.effectID = Effect.effectCount
        self.name = "Effect"
        self.properties = {
            "transparent": False,
            "alphaTest": False,
            "normalMapping": True,
            "dynamic": False,
            "castShadows": True,
            "castGI": True,
            "mainPass": True
        }
        self.assignments = {"Default": [], "Shadows": [], "Voxelize": []}
Exemplo n.º 42
0
 def __init__(self):
     DebugObject.__init__(self, "ShadowSource")
     self.valid = False
     ShadowSource._GlobalShadowIndex += 1
     self.index = ShadowSource._GlobalShadowIndex
     self.camera = Camera("ShadowSource-" + str(self.index))
     self.cameraNode = NodePath(self.camera)
     self.cameraNode.reparentTo(render)
     # self.camera.showFrustum()
     self.resolution = 1024
     self.atlasPos = Vec2(0)
     self.doesHaveAtlasPos = False
     self.sourceIndex = 0
     self.mvp = Mat4()
     self.sourceIndex = -1
     self.nearPlane = 0.0
     self.farPlane = 1000.0
    def __init__(self, image=None, parent=None, x=0, y=0, w=10, h=10, transparent=True, nearFilter=True):
        DebugObject.__init__(self, "BOnscreenImage")

        self.initialPos = Vec3(x + w / 2.0, 1, -y - h / 2.0)

        self._node = OnscreenImage(
            image=image, parent=parent, pos=self.initialPos, scale=(w / 2.0,  1, h / 2.0))

        if transparent:
            self._node.setTransparency(TransparencyAttrib.MAlpha)

        tex = self._node.getTexture()
        tex.setMinfilter(Texture.FTNearest)
        tex.setMagfilter(Texture.FTNearest)
        tex.setAnisotropicDegree(8)
        tex.setWrapU(Texture.WMClamp)
        tex.setWrapV(Texture.WMClamp)
    def __init__(self, showbase):
        DebugObject.__init__(self, "RenderingPipeline")
        self.showbase = showbase
        self.lightManager = LightManager()
        self.size = self._getSize()
        self.precomputeSize = Vec2(0)
        self.camera = base.cam
        self.cullBounds = None
        self.patchSize = Vec2(32, 32)

        self.temporalProjXOffs = 0
        self.temporalProjFactor = 2

        self.forwardScene = NodePath("Forward Rendering")
        self.lastMVP = None

        self._setup()
Exemplo n.º 45
0
    def __init__(self, classType, numElements):
        """ Constructs a new array, containing elements of classType and
        with the size of numElements. classType and numElements can't be
        changed after initialization """
        global ShaderStructArrays

        DebugObject.__init__(self, "ShaderStructArray")

        self.arrayIndex = len(ShaderStructArrays)
        ShaderStructArrays.append(self)

        self.debug("Init array, size =", numElements)
        self.classType = classType
        self.attributes = classType.getExposedAttributes()

        self.size = numElements
        self.parents = {}
        self.ptaWrappers = {}
        self.assignedObjects = [None for i in range(numElements)]

        for name, attrType in self.attributes.items():
            arrayType = PTAFloat
            numElements = 1

            if attrType == "mat4":
                arrayType = PTAMat4

            elif attrType == "int":
                arrayType = PTAInt

            # hacky, but works, will get replaced later by a parser
            elif attrType == "array<int>(6)":
                arrayType = PTAInt
                numElements = 6

            elif attrType == "float":
                arrayType = PTAFloat

            elif attrType == "vec2":
                arrayType = PTALVecBase2f

            elif attrType == "vec3":
                arrayType = PTALVecBase3f

            self.ptaWrappers[name] = [
                arrayType.emptyArray(numElements) for i in range(self.size)]
Exemplo n.º 46
0
    def __init__(self, classType, numElements):
        """ Constructs a new array, containing elements of classType and
        with the size of numElements. classType and numElements can't be
        changed after initialization """
        global ShaderStructArrays

        DebugObject.__init__(self, "ShaderStructArray")

        self.arrayIndex = len(ShaderStructArrays)
        ShaderStructArrays.append(self)

        self.debug("Init array, size =", numElements)
        self.classType = classType
        self.attributes = classType.getExposedAttributes()

        self.size = numElements
        self.parents = {}
        self.ptaWrappers = {}
        self.assignedObjects = [None for i in range(numElements)]

        for name, attrType in self.attributes.items():
            arrayType = PTAFloat
            numElements = 1

            if attrType == "mat4":
                arrayType = PTAMat4

            elif attrType == "int":
                arrayType = PTAInt

            # hacky, but works, will get replaced later by a parser
            elif attrType == "array<int>(6)":
                arrayType = PTAInt
                numElements = 6

            elif attrType == "float":
                arrayType = PTAFloat

            elif attrType == "vec2":
                arrayType = PTALVecBase2f

            elif attrType == "vec3":
                arrayType = PTALVecBase3f

            self.ptaWrappers[name] = [arrayType.emptyArray(numElements) for i in range(self.size)]
Exemplo n.º 47
0
    def __init__(self):
        DebugObject.__init__(self, "Effect")

        Effect.effectCount += 1

        self.effectID = Effect.effectCount
        self.shaderParts = {"Default": {}, "Shadows": {}}
        self.shaderObjs = {"Default": None, "Shadows": None}
        self.name = "Effect"
        self.properties = {
            "transparent": False,
            "alphaTest": False,
            "normalMapping": False,
            "dynamic": False,
            "castShadows": True,
            "castGI": True,
        }
        self.defines = {}
Exemplo n.º 48
0
    def __init__(self, name="DefaultRT"):
        DebugObject.__init__(self, "RenderTarget")
        self._targetFlags = {}
        self._bindMode = GraphicsOutput.RTMBindOrCopy
        self._depthbits = 24
        self._buffer = None
        self._quad = None
        self._sourceCam = base.cam
        self._sourceWindow = base.win
        self._width = -1
        self._height = -1
        self._name = name
        self._colorBits = 8
        self._auxBits = 8
        self._region = self._findRegionForCamera()
        self._enableTransparency = False
        self._layers = 0

        self.mute()
Exemplo n.º 49
0
    def __init__(self):
        """ Creates a new spot light. """
        Light.__init__(self)
        DebugObject.__init__(self, "SpotLight")
        self.typeName = "SpotLight"

        self.nearPlane = 0.5
        self.radius = 30.0
        self.spotSize = Vec2(30, 30)

        # Used to compute the MVP
        self.ghostCamera = Camera("PointLight")
        self.ghostCamera.setActive(False)
        self.ghostLens = PerspectiveLens()
        self.ghostLens.setFov(130)
        self.ghostCamera.setLens(self.ghostLens)
        self.ghostCameraNode = NodePath(self.ghostCamera)
        self.ghostCameraNode.reparentTo(Globals.render)
        self.ghostCameraNode.hide()
Exemplo n.º 50
0
    def __init__(self, name="RB"):
        """ Creates a new render buffer with the given name. The name should
        be descriptive as it will shown in pstats. """
        DebugObject.__init__(self, "RenderBuffer")
        self._name = name
        self._width = 0
        self._height = 0
        self._colorBits = 8
        self._auxBits = 8
        self._bindMode = GraphicsOutput.RTMBindOrCopy
        self._depthBits = 0
        self._internalBuffer = None
        self._targets = {}
        self._win = None
        self._layers = 0
        self._sort = 0
        self._multisamples = 0
        self._engine = None

        self.mute()
Exemplo n.º 51
0
    def __init__(self):
        DebugObject.__init__(self, "AbstractLight")
        self.debugNode = NodePath("LightDebug")
        self.visualizationNumSteps = 32
        self.dataNeedsUpdate = False
        self.castShadows = False
        self.debugEnabled = False
        self.bounds = OmniBoundingVolume()

        self.shadowSources = []
        self.lightType = self._getLightType()
        self.position = Vec3(0)
        self.color = Vec3(0)
        self.posterIndex = -1
        self.direction = Vec3(0)
        self.radius = 0.1
        self.typeName = ""
        self.sourceIndexes = PTAInt.emptyArray(6)
        for i in xrange(6):
            self.sourceIndexes[i] = -1
Exemplo n.º 52
0
    def __init__(self):
        """ Constructs a new directional light. """
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # If you change the split count, change DIRECTIONAL_LIGHT_SPLIT_COUNTS
        # in Shader/Includes/Configuration.include aswell! This is hardcoded
        # to improve performance
        self.splitCount = 6

        self.pssmTargetCam = Globals.base.cam
        self.pssmTargetLens = Globals.base.camLens
        self.pssmFarPlane = 150
        self.pssmSplitPow = 2.0
        self.sunDistance = 7000
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Exemplo n.º 53
0
    def __init__(self, pipeline):
        DebugObject.__init__(self, "SSLRManager")

        self.pipeline = pipeline

        # Add SSLR pass
        if self.pipeline.settings.enableSSLR:
            self.sslrPass = SSLRPass()
            self.sslrPass.setHalfRes(self.pipeline.settings.sslrUseHalfRes)
            self.pipeline.renderPassManager.registerPass(self.sslrPass)

            self.pipeline.renderPassManager.registerDefine("USE_SSLR", 1)

        if self.pipeline.settings.sslrUseHalfRes:
            self.pipeline.renderPassManager.registerDefine("SSLR_HALF_RES", 1)

        self.pipeline.renderPassManager.registerDefine(
            "SSLR_STEPS", self.pipeline.settings.sslrNumSteps)
        self.pipeline.renderPassManager.registerDefine(
            "SSLR_SCREEN_RADIUS", self.pipeline.settings.sslrScreenRadius)
Exemplo n.º 54
0
    def __init__(self, pipeline):
        DebugObject.__init__(self, "SSLRManager")

        self.pipeline = pipeline

        # Add SSLR pass
        if self.pipeline.settings.enableSSLR:
            self.sslrPass = SSLRPass()
            self.sslrPass.setHalfRes(self.pipeline.settings.sslrUseHalfRes)
            self.pipeline.renderPassManager.registerPass(self.sslrPass)

            self.pipeline.renderPassManager.registerDefine("USE_SSLR", 1)

        if self.pipeline.settings.sslrUseHalfRes:
            self.pipeline.renderPassManager.registerDefine("SSLR_HALF_RES", 1)
            
        self.pipeline.renderPassManager.registerDefine("SSLR_STEPS", 
            self.pipeline.settings.sslrNumSteps)
        self.pipeline.renderPassManager.registerDefine("SSLR_SCREEN_RADIUS", 
            self.pipeline.settings.sslrScreenRadius)
Exemplo n.º 55
0
    def __init__(self):
        """ Constructs a new directional light. You have to set a
        direction for this light to work properly"""
        Light.__init__(self)
        DebugObject.__init__(self, "DirectionalLight")
        self.typeName = "DirectionalLight"

        # If you change the split count, change DIRECTIONAL_LIGHT_SPLIT_COUNTS
        # in Shader/Includes/Configuration.include aswell! This is hardcoded
        # to improve performance
        self.splitCount = 5

        self.pssmTargetCam = Globals.base.cam
        self.pssmTargetLens = Globals.base.camLens
        self.pssmFarPlane = 150.0
        self.pssmSplitPow = 2.0
        self.updateIndex = 0

        # A directional light is always visible
        self.bounds = OmniBoundingVolume()
Exemplo n.º 56
0
    def __init__(self):
        """ Creates a new ShadowSource. After the creation, a lens can be added
        with setupPerspectiveLens. """
        self.index = self._generateUID()

        DebugObject.__init__(self, "ShadowSource-" + str(self.index))
        ShaderStructElement.__init__(self)

        self.valid = False
        self.camera = Camera("ShadowSource-" + str(self.index))
        self.cameraNode = NodePath(self.camera)
        self.cameraNode.reparentTo(Globals.render)
        self.resolution = 1024
        self.atlasPos = Vec2(0)
        self.doesHaveAtlasPos = False
        self.sourceIndex = 0
        self.mvp = Mat4()
        self.sourceIndex = -1
        self.nearPlane = 0.0
        self.farPlane = 1000.0
        self.converterYUR = None
    def __init__(self, classType, numElements):
        DebugObject.__init__(self, "ShaderStructArray")

        self.debug("Init array, size =", numElements, ", from", classType)
        self.classType = classType
        self.attributes = classType.getExposedAttributes()

        self.size = numElements
        self.parents = {}

        self.ptaWrappers = {}

        for name, attrType in self.attributes.items():
            arrayType = PTAFloat
            numElements = 1

            if attrType == "mat4":
                arrayType = PTAMat4

            elif attrType == "int":
                arrayType = PTAInt

            # hacky, but works
            # might get replaced later
            elif attrType == "array<int>(6)":
                arrayType = PTAInt
                numElements = 6

            elif attrType == "float":
                arrayType = PTAFloat

            elif attrType == "vec2":
                arrayType = PTALVecBase2f

            elif attrType == "vec3":
                arrayType = PTALVecBase3f

            self.ptaWrappers[name] = [
                arrayType.emptyArray(numElements) for i in xrange(self.size)
            ]
    def __init__(self, pipeline):
        DebugObject.__init__(self, "GlobalIllumnination")
        self.pipeline = pipeline

        self.qualityLevel = self.pipeline.settings.giQualityLevel

        if self.qualityLevel not in self.QualityLevels:
            self.fatal("Unsupported gi quality level:" + self.qualityLevel)

        self.qualityLevelIndex = self.QualityLevels.index(self.qualityLevel)

        # Grid size in world space units
        self.voxelGridSize = self.pipeline.settings.giVoxelGridSize
        
        # Grid resolution in pixels
        self.voxelGridResolution = [32, 64, 128, 192][self.qualityLevelIndex]

        # Has to be a multiple of 2
        self.distributionSteps = [16, 30, 60, 90][self.qualityLevelIndex]
        self.slideCount = int(self.voxelGridResolution / 8) 
        self.slideVertCount = self.voxelGridResolution / self.slideCount       

        self.bounds = BoundingBox()
        self.renderCount = 0

        # Create the task manager
        self.taskManager = DistributedTaskManager()

        self.gridPosLive = PTALVecBase3f.emptyArray(1)
        self.gridPosTemp = PTALVecBase3f.emptyArray(1)

        # Store ready state
        self.readyStateFlag = PTAFloat.emptyArray(1)
        self.readyStateFlag[0] = 0

        self.frameIndex = 0
        self.steps = []