1 registered members (AndrewAMD),
177
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
More than 4 entskins
#467977
09/12/17 02:35
09/12/17 02:35
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
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.
|
|
|
Re: More than 4 entskins
[Re: jumpman]
#467988
09/12/17 10:08
09/12/17 10:08
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
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 xPAnd build the UVmap using the left half of the image, so the normalmap coord into the shader will be:
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:
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...
|
|
|
Re: More than 4 entskins
[Re: txesmi]
#467994
09/12/17 14:26
09/12/17 14:26
|
Joined: Jun 2010
Posts: 212
tagimbul
Member
|
Member
Joined: Jun 2010
Posts: 212
|
you can use BMAP's directly from lite_c lite_c:
BAMP* my_image = "test.png";
shader:
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
Last edited by tagimbul; 09/12/17 14:29.
|
|
|
Re: More than 4 entskins
[Re: txesmi]
#467999
09/12/17 16:01
09/12/17 16:01
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
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.
|
|
|
Re: More than 4 entskins
[Re: jumpman]
#468001
09/12/17 17:23
09/12/17 17:23
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
Serious User
|
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
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.
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.
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
|
|
|
Re: More than 4 entskins
[Re: txesmi]
#468007
09/12/17 20:14
09/12/17 20:14
|
Joined: Jun 2010
Posts: 212
tagimbul
Member
|
Member
Joined: Jun 2010
Posts: 212
|
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
Last edited by tagimbul; 09/12/17 20:32.
|
|
|
|