More than 4 entskins

Posted By: jumpman

More than 4 entskins - 09/12/17 02:35

hello! Was wondering if anyone has any ideas for sampling more than 4 internal textures of a model in a shader. The manual clearly states that only entskin1...entskin4 can be declared in the shader.

I can very easily just use mtlSkin1-4, which are "external" textures outside of the model, such as a sky cube, which is ok to declare and use. But I am trying to cram one more map into my shader, without having to write a new shader that points to a new external map.

Here is my skin list within the model:

Skin texture 1: Diffuse and Alpha...RGB and alpha are used
Skin texture 2: Rim lighting...RGB is used, Alpha isnt used by shader
Skin texture 3: ShinyMap...RGB is used, Alpha is used
Skin texture 4: Normal Map...RGB is used, Alpha isnt used by shader

Finally, I want to use a 5th texture, a sub surface map for some fake Subsurface scattering. This map is RGB, alpha isnt used. So as you can see, if I want to make multiple characters, each with their own subsurface map and subsurface color, I would need to make a different shader for each subsurface map.

I guess I could use vecSkill and perform some if statements and link the single shader to different SSS maps depending on the character, but maybe theres another clever way. Maybe I could use the unused Alpha channels of certain textures and use these as RGB values for the SSS map.

Curious if anyone else has any ideas.
Posted By: txesmi

Re: More than 4 entskins - 09/12/17 05:09

Hi,
You could use a single bitmap as texture atlas with four half-resolution effect bitmaps, if you don't mind the resolution lost.
Posted By: jumpman

Re: More than 4 entskins - 09/12/17 05:27

how does that work?

does one of the models skins need it's UV to be wrapped differently? Is this done in a shader, or in the model file itself?
Posted By: txesmi

Re: More than 4 entskins - 09/12/17 10:08

Hi,
you can perform both depending on the best choice for your needs.

You could save diffuse and normals in a image near to this:

but without that ugly vertical white stripe in the middle xP

And build the UVmap using the left half of the image, so the normalmap coord into the shader will be:
Code:
float2 nCoor = inTex;
nCoor.x += 0.5f;



But as I suggested in my previous post, you could also use an effectmap, on same, twice or whatever resolution of the colormap:
Code:
float4 Color = tex2D ( sDiff, inTex );
float2 UpLeftQuarter = inTex * 0.5f;
float4 Normal = tex2D ( sEffects, UpLeftQuarter );
float2 UpRightQuarter = float2 ( UpLeftQuarter.x + 0.5f, UpLeftQuarter.y );
float4 Specular = tex2D ( sEffects, UpRightQuarter );
// and so...

Posted By: tagimbul

Re: More than 4 entskins - 09/12/17 14:26

you can use BMAP's directly from lite_c

lite_c:
Code:
BAMP* my_image = "test.png";



shader:
Code:
texture my_image_bmap;

sampler sTex = sampler_state
{
	Texture = <my_image_bmap>;
}



if you make global bmap's or arrays you can use this thing in shader if you add a _bmap or _var to the name of your objekt
Posted By: jumpman

Re: More than 4 entskins - 09/12/17 16:01

wow...that is very clever thank you, I didnt know you could offset a texture lookup position!

I half implemented the first solution, until I saw you cant have different UV layouts for each skin. In skin1, which is the color/diffuse, the UV map is spread out all over it. In skin2, which has the "double texture" dimension(rim light and SSS, 128 x 256), I cannot move the UV to the left without effecting every other skin. I would need to move the UV to the left on every skin correct? All skins must have the same ratio in this case...which means the Color map in skin1, would need a blank spot to the right.

Does having a dedicated effect map in an entity skin overcome this? I dont see how it can, since model skins still need UV layouts in the skins.
Posted By: jumpman

Re: More than 4 entskins - 09/12/17 17:15

hi tagimbul,

that changes the texture globally for that material. What I want is to have a way to use a 5th entity texture, which can be different for every model....but all using the same FX file.
Posted By: txesmi

Re: More than 4 entskins - 09/12/17 17:23

UV layouts are not skin related but mesh related. Each vertex has two sets of UV coords available. You will need to set both UV set in the model, you know.
Code:
in float2 inTex1 : TEXCOORD0
in float2 inTex2 : TEXCOORD1



Those texture atlas examples are just examples. I did not think to much about them.

In the first example, you will probably prefer to mantain the model UV coords filling the texture, as they usually are, and simply scale them for your needs.
Code:
float2 diffCoor = float2 ( inTex.x * 0.5f, inTex.y );
float2 normalCoor = float2 ( diffCoor.x + 0.5f, inTex.y );



I was just trying to explain that you can use the models UV coords for your advantage but it does not needed to be that way. Blank spots should not be in the planning, true wink
Posted By: tagimbul

Re: More than 4 entskins - 09/12/17 20:14

i have a idea =)
your 4 textures:
RGBA, RGB, RGBA, RGB
size:
512x512

combine
RGBA + RGBA
RGB + RGB

texture 1 with 2:
1024x512
texture 3 with 4:
1024x512

and in shader scale in tex2D, X with 0.5

and if you want use mip's

all 4 texture in one:
1024x1024

and scale in tex2D Y with 0.5 too

(i think mips need same x and y size. right?)

edit:

ent texture 1 = 512x512 your sub surface map with the UV
ent texture 2 = texture 1+2 1024x512
ent texture 3 = texture 3+4 1024x512
ent texture 4 = free

positive:
its work ^^
negativ:
reading biger texture / need more performance

i dont know.. what is faster? read 2 texture in 512x512 or one texture in 1024x512?...

edit2:

or:

ent texture 1 = 512x512 model color texture
ent texture 2 = 1024x512 texture 2+3
ent texture 3 = 1024x512 texture 4+5
ent texture 4 = free
Posted By: jumpman

Re: More than 4 entskins - 09/15/17 00:13

Hi everyone, Ive used Txesmi's method, and it seems to work so far!!! Thank you for all your input everyone, you all are a clever bunch of game developers laugh
© 2024 lite-C Forums