Welcome, Guest.
Username: Password: Remember me

TOPIC: A Question for Coders Familiar with ReShade's HLSL

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #1

I'm trying to figure out what exactly these texture2D coding's are. Here is an example:
texture2D texExample { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R16F; MipLevels = 5; };

and
]texture2D texExample { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R32F; MipLevels = 5; };

This seems to be unique to ReShade. What would be the PURE HLSL implementation of these?? I'm trying to port things over to a system that doesn't have code like that.

Thanks.
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #2

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1385
ReShade shaders are written in the ReShade FX language, which is very similar to HLSL, but has a few additional features. See github.com/crosire/reshade-shaders/blob/master/REFERENCE.md for reference.

This particular feature is not possible with HLSL alone. It's a unique feature to ReShade which allows to define textures in shader code that does exist in neither HLSL, nor GLSL. In those you can only reference textures that were created in application code.
Cheers, crosire =)
Last Edit: 3 months 2 days ago by crosire.
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #3

Crapola! So, the only alternative then for HLSL would be to actually create a texture? So I would have to use this:
texture2D  myTexture  <stringSource = "filePath\myCustomTexture.dds"; >

...????

So what actually goes on with ReShade's implementation of this unique feature? "BUFFER_WIDTH" is equivalent to "Screen Width", right? So, how could I create a texture that would satisfy what ReShade does in these instances and port it directly to HLSL? Using the post above, I would need a texture that is (for a 1440p display) 2560x1440, has an alpha channel, and five mipmap levels? Am I misunderstanding? What would be an effective way to translate that native ReShade stuff into HLSL?

Thanks for your help, crosire!
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #4

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1385
The "< X = Y >" syntax is unique to ReShade FX too. HLSL has annotations of the form "< TYPE X = Y >", but they don't do anything if not implemented by the application. So no, this is no alternative, it won't work in plain HLSL too.

You simply cannot create a texture in HLSL code. You can only do that in the client-side application code (which would be written in C++ or similar).
Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Malonn

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #5

crosire comes baring bad news. :(

So, just out of curiosity, what is actually happening behind the scene with ReShade when that sytax is called?

And a "thank you" is more than deserved in this case.
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #6

  • Marty McFly
  • Marty McFly's Avatar
  • Offline
  • We've tried nothing and we're all out of ideas!
  • Posts: 609
  • Thank you received: 716
One should note that your syntax tries to load a static texture from any file. Textures in shadercode are different, they can change over time. Basically all you can see onscreen in a game is the current state of the COLOR texture - which changes frame by frame. A screenshot is basically just a dump to disk of the current state of the color texture at the point where you pressed the screenshot key. If you load a texture from a file, ReShade creates a texture in memory very similiar to the color texture that holds what is onscreen atm but fills it with the static color information from the texture you specified.
texture2D texExample { Width = BUFFER_WIDTH; Height = BUFFER_HEIGHT; Format = R16F; MipLevels = 5; };
creates a texture a pass can read from and more importantly, write to. It's empty by default and a pass needs to fill it with data. Almost all the time this data is derived from the screen texture in any way so it's dynamic over time.
texture2D texNoise  <string source = "noise.png";> { Width = 64;Height = 64;Format = RGBA8;};
creates a texture with the static data from the noise.png specified. You cannot write to such a texture with a pass. Oblivion Reloaded supports such a thing, so you can load your own external textures.

However as crosire said, you cannot create a texture like the first one in Oblivion Reloaded.
The administrator has disabled public write access.
The following user(s) said Thank You: Malonn

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #7

Ah. Understanding what is happening is good. Thank you, Marty! So basically, I have to take it up with the author of Oblivion Reloaded. Now that I better understand what is going on, I will ask him what it would take to implement something like that.

I'm thinking my next question is going to be dense in nature and annoying, but WTH...
Is there a way to "loophole" the writable texture feature that ReShade implements? For the record, I'm assuming the answer is "no" and that you all have said so 3 times now, but...
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #8

  • crosire
  • crosire's Avatar
  • Offline
  • Posts: 2437
  • Thank you received: 1385
No =).
Oblivion Reloaded needs to support custom render targets for that and set up the target texture as writable.
Cheers, crosire =)
The administrator has disabled public write access.

A Question for Coders Familiar with ReShade's HLSL 3 months 2 days ago #9

Alrighty. I will take this to the OR developer then.

Thanks all.
The administrator has disabled public write access.