9 個の投稿 / 0 new
最終投稿
#1 2018-01-13 16:08

Normal map in RayCast Shader

Can you help me?

I'm trying use normal map in raycast shader, but I have a lot of problem with it.
This is my problems:

https://imgur.com/EnXxLCI
https://imgur.com/QO3hAGS
https://imgur.com/V8lzhWU

I was try use PMX method, but results was... "similar", so, I try this method:
https://youtu.be/p0HbqgqMRqg

Furthermore, when normal map finally work, model is darker and... nothing more, script in materials 2.0, not change, only 4 lines, from 28 to 31 to this:
#define NORMAL_MAP_FROM 1
#define NORMAL_MAP_TYPE 0
#define NORMAL_MAP_UV_FLIP 0
#define NORMAL_MAP_FILE "1.png"

1 is picture in png, it's normal map. Normal maps, material 2.0 (modified) and material_common_2.0 is in separate folder from raycast.
https://imgur.com/UGSRR9E <- in this folder is everything (material 2.0, material_commons, and normal maps)
and that how look everything, for example, folder with hair:

https://imgur.com/8UsWCiy

Somebody can tell me what I should do that finally work?

2018-01-13 16:25

Make sure that the texture file in mapped correctly. If the .fx file is in the Materials folder, but the texture file is in a subfolder, then you need to specify exactly where it is.

Example:

#define NORMAL_MAP_FROM 1
#define NORMAL_MAP_TYPE 0
#define NORMAL_MAP_UV_FLIP 0
#define NORMAL_MAP_FILE "_MaterialMap/Concrete01.jpg"

The texture file in my example is in a subfolder called "_MaterialMap".

One of your errors says that it cannot convert "const float3 to float4". It is talking about hexadecimal colors. Look through your code for anything that says "float3" or "float4". It may be in the first section (the ALBEDO section). It should look something like this:

#define ALBEDO_MAP_FROM 3
#define ALBEDO_MAP_UV_FLIP 0
#define ALBEDO_MAP_APPLY_SCALE 1
#define ALBEDO_MAP_APPLY_DIFFUSE 1
#define ALBEDO_MAP_APPLY_MORPH_COLOR 0
#define ALBEDO_MAP_FILE "albedo.png"

const float3 albedo = float3(247, 199, 149) / 255;
const float2 albedoMapLoopNum = 1.0;

Do you see the float3? Those numbers in the parenthesis are defining a color (Red, Green, Blue). The numbers range from 0 (Black) to 255 (the primary color). If you add a fourth number to it you will get an error.

2018-01-13 16:36

Each png files have his own material 2_0, for each folder is one material_commons 2.0
https://i.imgur.com/8UsWCiy.png

About colors, I have this:
#define ALBEDO_MAP_FROM 3
#define ALBEDO_MAP_UV_FLIP 0
#define ALBEDO_MAP_APPLY_SCALE 0
#define ALBEDO_MAP_APPLY_DIFFUSE 1
#define ALBEDO_MAP_APPLY_MORPH_COLOR 0
#define ALBEDO_MAP_FILE "albedo.png"

const float3 albedo = 1.0;
const float2 albedoMapLoopNum = 1.0;

2018-01-13 16:45

Try moving your .fx files and the texture files to the Materials folder. Do not create your own subfolders. And avoid using spaces in file names. Computer code does not like spaces. You_can_use_an_underscore_instead.

Your float3 problem is not in the ALBEDO section. Check the other sections.

2018-01-13 16:49

If you want to put your textures in a subfolder, that is fine as long as you give the .fx file the exact path to the file.

2018-01-13 16:52

I forgot to mention that if you are using the normalmaps in the Skin folder, you should put the .fx file in the Skin folder also.

2018-01-13 17:14

Did you move the material_common_2.0.fxsub into the subfolder that you created? That could be problem. I would put it back in the Materials folder.

2018-01-13 17:20

Yes, but now all FX I back to "materials" and the png files move to _MaterialMap,
and change a little script, everything work :)
I don't have any error, I think I was have something incorrect in script, thanks a lot for help :D

2018-01-13 17:24

You are welcome. Glad I could help.