Jump to content

Multiple Render Targets in Shader


Recommended Posts

  • 1 month later...
  • 6 months later...
  • 2 months later...
  • 1 month later...

I have a question.

I want to create 2d mirror like in this video:

I tried to replace dxDrawMaterialLine3D with dxDrawImage ( 100, 0, 300, 100, self.shader) in CMat3DProj:draw() function. In result I have black rectangle instead of mirror.

How to make it work like that?

Link to comment

The script in that video was a concept made back in 2011! with many flaws, you can download the source code if you haven't yet:

https://community.multitheftauto.com/index.php?p= ... ls&id=2870

There where no shader functions in it, I just wanted to find a use for dxCreateScreenSource.

The main problem is that you have to devote some frames to simulate the second camera, and you need a way to render the correct image in the right place (I used 2 render targets, one is full screen and the other is the mirror)

Link to comment

Technical idea behind your script is very smart Wojak. But unfortunately those two problems - fps drop and sound issues are too much. I'm building scripts for a new gamemode and script provided by Ren can be a solution to somehow introduce something that will look like rear view mirrors without hurting gameplay too much.

Link to comment

The GTA:SA engine was newer designed to support more then one camera, so making a perfect mirror is not possible even with the Ren's script.

The only idea tat come's to mind should allow to simulate left or right side mirror with full FPS and no sound issues (but testing is required):

1) You set the camera matrix to its max FOV (180) and rotate the center of viewpoint until the left (or right) side of the 180 viewpoint would show the same as 70(default) viewpoint.

2) You get the screen source.

3) You create two render targets (one full screen and one for the mirror).

4) You cut the 70/180% of the screen source from the left (or right depending on the rotation from step one), you stretch it and draw on the full screen render target

5) You cut some from the other side of the screen source and draw it to the other render target.

I don't know if you understand what I mean, but in theory this should work, but there may be some other problems witch this (stretched default HUD, low quality dune to stretching and such).

Link to comment

I have updated the cam2rt resource. A new class cam2RTImage lets you get the render target and draw things as an image. Also remember that the effects have range of 60 units (you might change that - line 12, 13 in the class files).

If you change field of view to values above 100 degrees - things start to glitch (especially in vehicles). But for ped - up to 170 degrees seem to look bearable).

To get standard (70 degree ) field of view - after setting a ridiculously high value - you can use this simple shader:

https://www.dropbox.com/s/ih8hrkdgkcukg ... v.zip?dl=0

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...