Forums Gallery LOGIN |REGISTER

Community Archive is read-only - Here you can view content recorded up until February 2017. To join the latest discussions visit our new forums


New Viewport + RENDER TO TEXTURE

Please use this forum for questions on C++, Lua, XML, and any other languages used in Crysis modding.


 

User avatar danilochavez
Intern Dev
Intern Dev
 
Posts: 130
Member since: 17.11.2010, 10:35
Location: Guatemala
Likes: 0

Postby danilochavez » 18.01.2011, 01:41

DURLI, share with us your code...I tried to found the problem but you have found it....
E=mc^2
This is more general E^2=(pc)^2+(mc^2)^2
and Me=h*fcompton/c^2 (Me is electron's mass)
User avatar DURLI
Regular Dev
Regular Dev
 
Posts: 545
Images: 2
Member since: 21.10.2009, 19:52
Location: Slovakia, EU
Likes: 6

Postby DURLI » 18.01.2011, 10:39

I´ll release to when it will be finished.

Anyways, just cant figure out how overwrite material slot 0 ( diffuse map) with my data from output.
I was looking at CScan , but thats not working. Any help ?
Image
C++ || C# || 3D Artist || 2D Artist || UI Artist || Animator
User avatar i59
Producer
Producer
 
Posts: 2041
Images: 1
Member since: 19.03.2009, 12:21
Location: Sweden
Likes: 38

Postby i59 » 18.01.2011, 16:11

Ugly code here, but I believe you can use the UpdateTextureInVideoMemory func:

Code: Select all
gEnv->pRenderer->UpdateTextureInVideoMemory(pMat->GetShaderItem().m_pShader->GetTexId(),
                  reinterpret_cast<unsigned char*>(pImage), 0, 0, res.x, res.y, eTF_A8R8G8B8);
Last edited by i59 on 18.01.2011, 16:23, edited 2 times in total.
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 18.01.2011, 18:53

Code: Select all
pMat->GetShaderItem().m_pShader->GetTexId()


Ah, why i havent seen this?! Thx i59, ive asked about this in a nother thread, but no one answerd so i used a predefined material, but if this work it would be much more flexible. Ill try this, thx again. :))

Blue
User avatar i59
Producer
Producer
 
Posts: 2041
Images: 1
Member since: 19.03.2009, 12:21
Location: Sweden
Likes: 38

Postby i59 » 18.01.2011, 19:17

Created a node (for Crysis Wars) which is able to render to screen, and *almost* to texture. (I believe the new data is not correctly reinterpreted when sent to UpdateTextureInVideoMemory.)

If anyone is aware of a solution to this, please do let me know :tongue:

Download it here. Please note that it's experimental, WIP and buggy. Code is very ugly at the moment, will rework it once I get render to texture working properly.

To use the Render to Screen functionality:
Assign a Player or Camera entity to the node, select the width / height and then activate the Create port. Please note that this is very much experimental and is only meant to show how this can be done.
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 18.01.2011, 19:52

Hi again ^^

think i can help with this. Perhaps you have seen that i wrote on a nother page to z_kaiser that he must regroup the information in the array (ive thought he also would make a texture - but he displayed it direct to the screen ^^).

If you read the buffer (if im not wrong (could also be!)) - you got the data in format: A B G R -> if you dosnt dump them direct to the dds files and go the way over forcerelease and realod - you must prepare this data before you can load it direct to the video buffer. As you know, the right way for the video buffer must be: A R G B. So after fliping the lines - flip also the 8 bit from red and blue(^^).


EDIT:
Ive taken a look in my old code, this i used to flip the lines (for horizontal switch) and to set the colors in the right way. It could be done better (quick & dirty progged ^^), but it should help to show what i mean.

Code: Select all
pRenderer->ReadFrameBufferFast(uTexSource,  iWidth, iHeight);

unsigned int * uTemp = new unsigned int[iWidth*iHeight];
for (int x01 = 0x0;  iHeight > x01; ++x01 )
{
   memcpy(static_cast<void*>(&uTemp[iWidth*x01]), static_cast<void*>(&uTexSource[(iWidth*iHeight)-(iWidth*(x01+1))]), 4*iWidth);
}

for (int x01 = 0x0;  (iHeight*iWidth) > x01; ++x01 )
{
   uTemp[x01] = ((uTemp[x01]>>24)<<24) | ((uTemp[x01]<<24)>>8) | ((uTemp[x01]>>8)<<24>>16) | ((uTemp[x01]<<8)>>24);
}
            
pRenderer->UpdateTextureInVideoMemory(pTex->GetTextureID(), reinterpret_cast<unsigned char*>(uTemp), 0, 0,iWidth, iHeight, eTF_X8R8G8B8/*eTF_A8R8G8B8*/);

delete [] uTemp;


--------------

Code: Select all
gEnv->pRenderer->EF_GetTextureByID(m_renderTarget)->GetData32()


:cheesy: On this point i was also last year as i tryed to integrate the rendertarget tec in my avicreation node (but hasnt worked ^^). :cheesy:

--------------

One question, do you get a picture with:
Code: Select all
SHDF_ALLOWHDR | SHDF_ZPASS | SHDF_ALLOWPOSTPROCESS | SHDF_ALLOW_AO | SHDF_ALLOW_WATER | SHDF_SORT


Perhaps i do something wrong, but i must use a nother bitconfig to get a original like picture to the display. :unsure: Perhaps because im using crysis and not wars...


greetings, Blue

EDIT: Integrated some old code snippets
Last edited by Blue on 18.01.2011, 20:30, edited 2 times in total.
User avatar i59
Producer
Producer
 
Posts: 2041
Images: 1
Member since: 19.03.2009, 12:21
Location: Sweden
Likes: 38

Postby i59 » 18.01.2011, 22:40

Thanks for the suggestions!

About the render world flags, yes it does render correctly when using them. I tried using the gEnv->pRenderer->GetRenderType() | SHDF_ALLOW_WATER setup, but it only resulted in issues with blur and other effects.

Your issues might be caused due to you using Crysis 1. Perhaps the setup works differently there? Try checking if there are additional render world flags in your setup, or if the flownode setup is different.
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 19.01.2011, 00:35

Thanks for the suggestions!


Was me a pleasure, you helped me also. ;)


About the render world flags, yes it does render correctly when using them. I tried using the gEnv->pRenderer->GetRenderType() | SHDF_ALLOW_WATER setup, but it only resulted in issues with blur and other effects.


Hm, yes i know those flags - but they doesnt work. ^^ Getrendertype works perfect for me if i work only with readframebuffer - but not with the rendertargets. Ive also used the drawflags, but they doesnt work as well. Perhaps wrong combination or something like this, crysis framework is sometimes realy strange u know. ;) So ive created a bitfield (try & error ^^), that works.


Blue

EDIT: *rofl* Forget what ive written with the bitfield - i thought i need some higher tags than 0x3ff but i was wrong. My system works with 0x0 (higher flags than SHDF_NOASYNC have no effect ^^) - but not with other flags, crs framework is realy realy strange sometimes. :rolleyes:
EDIT2: ok fine, i wont post anymore, all i say is wrong, atm im playing with this stuff a little bit and and now... one of the lower tags work... -_-
or to be precise -> some flags wont work -> i cant see a difference by using the others xD
Last edited by Blue on 19.01.2011, 14:00, edited 7 times in total.
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 21.01.2011, 00:47

Sry, ill start a new post for this (dont hit me pls).

@i59

So ive tryed it with many flags, but it doesnt work. I also used your node (ive changed it a little bit to make him work with crysis 1).

[YOUTUBE]hRzthla5kDg[/YOUTUBE]

Here you can see whats the result is, its more or less the same if i use the hdr or postprocess flag in combination with the rendertargets.
This fit perfect if i use it in combination with readframebufferfast().

Here i have made a small video with the way over rendertargets and readframebufferfast(). First halfe is with rendertargets, it shows that water wont be displayed - and that though it has the water flag. Also some particles wont be displayed, realy strange. -_-
Ah and not to forget - it seems the rendertarget texture has some "holes" where the whater should be... ?(

[YOUTUBE]qtw9jjzd30Q[/YOUTUBE]


Has someone the same or similiar problems with the rendertargets/renderflags or are im the only one whit this results?


Blue
User avatar z_kaiser
Just getting started
Just getting started
 
Posts: 52
Member since: 02.04.2009, 12:17
Likes: 0

Postby z_kaiser » 24.01.2011, 14:15

Hi again Blue,

I have the same problem with the rendertargets. I can´t see the water, neither the sky... Can you see the sky using rendertargets????
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 24.01.2011, 15:01

Hey z_kaiser,

Ahm, yes i can see the sky (if you are talking about enviroment->skybox), ill make today a new video, because some people cant see the one ive made as presentation for the released mvp plugin. Atm ive send i59 the my code. Perhaps he see's something i dont see. If you wanna something to compare your result, you could download the released plugin.

<To the thread>


greetings, Blue

EDIT: k i made a new video(without sound) + 3 screenshots, there you can see that my sky box is in the viewport, ive colord also a small water volume with layer painter, so you can see that the layer painting is displayed, but not the whater.
Last edited by Blue on 24.01.2011, 16:23, edited 1 time in total.
User avatar z_kaiser
Just getting started
Just getting started
 
Posts: 52
Member since: 02.04.2009, 12:17
Likes: 0

Postby z_kaiser » 21.02.2011, 10:11

Hi again Blue,

I´ve finishing my viewport node and finally I get it working with the skybox and I can see all types of elements, including the water. I have attached two images of the result.
Hope to see you in other posts :)

Greetings
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 21.02.2011, 12:20

Hey realy nice man. :)

I havent worked anymore on this mod, because of some rely odd results. Only with the graphic settings "high", my rendertargets drawing the right scene (whater/hdr/shadow). =_=

Can i aske you what graphic setting youre mod is using? (low/mid/high/very high - dx9 / dx10 - crysis 1 / crysis wars)?

Because i59 has sayed his system works very well with crysis wars - but with my crysis 1 i have many problems with the render and drawflags in the different grapic specs.


best regards, blue
User avatar z_kaiser
Just getting started
Just getting started
 
Posts: 52
Member since: 02.04.2009, 12:17
Likes: 0

Postby z_kaiser » 21.02.2011, 13:06

Hi,

I work with high settings (what I consider high settings because I have my owns systemcfgoverride.cfg), dx9 and crysis1

I obtain the same result with my lowest configuration (10FPS improvement from repect HIGH settings)
Last edited by z_kaiser on 21.02.2011, 13:11, edited 1 time in total.
User avatar Blue
Junior Dev
Junior Dev
 
Posts: 328
Member since: 18.02.2009, 10:55
Likes: 22

Postby Blue » 21.02.2011, 14:40

Hey z_kaiser, thx for your reply. Because of your post, ive reopend the mod and tryed it now on my old xp - dx9 pc, but it doesnt work. Ive also changed the flags as ive done under dx10, but i dosnt found a solution for this. Perhaps i have a basic failer in my viewport system, could be. Think ill clean the code and load it with the newest plugin version up to crymod. Shall someone else find a solution, ill only became crazy with this stuff. :happy:

Blue

EDIT:
K, ive cleand up the code and uploaded it to crymod. Now i must only wait for the mods. ^^ Ill link the source file also in my MVP Thread.

@z_kaiser:
If you are for purpose in third person to show yourselfe in the viewport, my code could be a little bit of interest for you, because i render the player model in the viewports, even if im not in third person. :)
Last edited by Blue on 21.02.2011, 19:11, edited 2 times in total.