示例#1
0
        // Handles generating a cinematic frame if needed
        public static void RB_BindVariableStageImage(TextureStage texture, float *shaderRegisters)
        {
            if (texture.cinematic != null)
            {
                if (r_skipDynamicTextures.Bool)
                {
                    globalImages.defaultImage.Bind(); return;
                }

                // For multithreading. Images will be 1 fame behind..oh well
                if (texture.image != null)
                {
                    // The first time the image will be invalid so wont bind, so bind black image
                    if (texture.image.Bind() == false)
                    {
                        globalImages.blackImage.Bind();
                    }
                    // Save time to display
                    texture.image.cinmaticNextTime = (int)(1000 * (backEnd.viewDef.floatTime + backEnd.viewDef.renderView.shaderParms[11]));
                    // Update next time
                    globalImages.AddAllocList(texture.image);
                }

                //// offset time by shaderParm[7] (FIXME: make the time offset a parameter of the shader?)
                //// We make no attempt to optimize for multiple identical cinematics being in view, or for cinematics going at a lower framerate than the renderer.
                //CinData cin = texture.cinematic.ImageForTime((int)(1000 * (backEnd.viewDef.floatTime + backEnd.viewDef.renderView.shaderParms[11])));
                //if (cin.image != null) globalImages.cinematicImage.UploadScratch(cin.image, cin.imageWidth, cin.imageHeight);
                //else globalImages.blackImage.Bind();
            }
            //FIXME: see why image is invalid
            else if (texture.image != null)
            {
                texture.image.Bind();
            }
        }
示例#2
0
        public static void RB_GetShaderTextureMatrix(float[] shaderRegisters, TextureStage texture, float *matrix)
        {
            matrix[0]  = shaderRegisters[texture.matrix[0][0]];
            matrix[4]  = shaderRegisters[texture.matrix[0][1]];
            matrix[8]  = 0f;
            matrix[12] = shaderRegisters[texture.matrix[0][2]];

            // we attempt to keep scrolls from generating incredibly large texture values, but center rotations and center scales can still generate offsets that need to be > 1
            if (matrix[12] < -40f || matrix[12] > 40f)
            {
                matrix[12] -= (int)matrix[12];
            }

            matrix[1]  = shaderRegisters[texture.matrix[1][0]];
            matrix[5]  = shaderRegisters[texture.matrix[1][1]];
            matrix[9]  = 0f;
            matrix[13] = shaderRegisters[texture.matrix[1][2]];
            if (matrix[13] < -40f || matrix[13] > 40f)
            {
                matrix[13] -= (int)matrix[13];
            }

            matrix[2]  = 0f;
            matrix[6]  = 0f;
            matrix[10] = 1f;
            matrix[14] = 0f;

            matrix[3]  = 0f;
            matrix[7]  = 0f;
            matrix[11] = 0f;
            matrix[15] = 1f;
        }