JayFoxRox / nv2a-re

A tool to assist in reverse engineering the NV2A
5 stars 1 forks source link

Example shaders not online #2

Open JayFoxRox opened 7 years ago

JayFoxRox commented 7 years ago

Currently there are no shaders included with nv2a-re to explain how to use it. I have 10 shaders offline, but I first have to clean them up.

JayFoxRox commented 7 years ago

I'm moving nv2a-re to my python-scripts in the future. Chances are I'll not upload examples anymore. So here is a not-clean example how to define constant values:

!!VSP1.0

# 0.0, 1.0, Inf, NaN
#const c[1] = 0x00000000 0x3F800000 0x7F800000 0x7FFFFFFF 

# Smallest denormal, smallest num, largest num
#const c[2] = 0x00000001 0x00800001 0x7F7FFFFF

# Random NaN or rarely Inf
#const c[3] = 0x7F800000 0x003FFFFF 0x7F801234

# Random denormal
#const c[4] = 0x00000000 0x007FFFFF 0x003FFFFF 0x001FFFFF

# Random numbers in range [2; 511[
#const c[5] = 0x40000000 0x03FFFFFF

# ???
#const c[6] = 0x00000000 0x7FFFFFFF

MOV R0, c[1];
MOV c[81], R0;
MOV R0, c[2];
MOV c[82], R0;
MOV R0, c[3];
MOV c[83], R0;
MOV R0, c[4];
MOV c[84], R0;
MOV R0, c[5];
MOV c[85], R0;
MOV R0, c[6];
MOV c[86], R0;

MOV R0, c[4];
ADD c[100].x, R0.x, R0.y;
SGE c[100].y, R0.x, R0.y;
SLT c[100].z, R0.x, R0.y;

MOV R0, c[3].z
MOV c[100].z, R0.x, R0.y;

END

You should also be able to define constants using #const c[2] = -11 +12 -1.3 1.4 etc. hex is just more convenient because you know what bits you'll end up getting and you can represent all NaN.