a special case of blending, how to?

Started by
6 comments, last by QuadMV 18 years, 8 months ago
Hi All, I have an object that is already textured using a pixel shader and 4 textures (+1 for the shading). It’s working perfectly. Now I’m taking a second pass with a different shader, and a different set of 4 textures (+1 shader texture). However, I want to control how much or little of the second pass gets applied to the base pass. If I’m using a pixel shader, do I need to enable this in it? Below is the pixel shader I’m using. I’m currently using the same one for both passes. Alternatively, I’d like to use a diffuse color on each vertex to control the amount of alpha between the base texture and the second pass, but I wasn’t sure I could do that while already using a shader? Any suggestions would be greatly appreciated, thanks. Quad Copy of the shader I’m using

ps_1_4

////////////////////////////////
// r0: alphamaps
// r1 - r4: textures
////////////////////////////////

// Sample textures
texld r0, t0
texld r1, t1
texld r2, t1
texld r3, t1
texld r4, t1

// Combine textures together based off of their alphamaps
mul r1, r1, r0.x
lrp r2, r0.y, r2, r1
lrp r3, r0.z, r3, r2
lrp r0, r0.w, r4, r3 

3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
Advertisement
Just output the vertex diffuse as part of the pixel shader output color (in r0.a). Enable alphablending, and use srcblend=srcalpha, destblend=one. This will just add alpha*color to the existing framebuffer value from your first pass.
cool thanks, let me try that and I'll let you know
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
I just realized, I don't really know shaders. The one I'm using someone else supplied. How to I set r0.a?

thanks
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
Is it as simple as :

r0.a = 128 // put what ever const value I want here?
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
You could do a constant, but you want your vertex diffuse, which is in v0.

So
"mov r0.a, v0.a" at the end

or for a constant
"def c0, 0, 0, 0, 0.5" at the top of the shader, after the version
"mov r0.a, v0.a" at the end of the shader.
Thanks, but I still need a little more help.

Quote:
srcblend=srcalpha, destblend=one


It's only partially working. I don't think this is what I want, but I haven't been able to determine the right combination yet.

I'm setting my diffuse color to one of the following:

0xFF000000
0xA0000000
0x80000000
0x30000000

The idea is to let 100% of the second pass show for textures that are close, and slowly have them fade out as the texture gets further away, showing more of the underlying color.

However, I don't want drastic color changes. When I use FF, I would expect the second pass to display the full colors of the now opaque texture, but instead it's tinted very heavily in YELLOW.

Any ideas what's going on?

Thanks


3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.
I think I got it. It seems that using:

_bothsrcalpha did the trick. Maybe someday I'll understand just what all these mean.

	pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_BOTHSRCALPHA );	pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE );


Thanks for all the help, I appreciate it.

Quad
3DMUVE is an amateur game development team, and the designer and developer of a new gaming technology “MUVE” for the gaming industry.

This topic is closed to new replies.

Advertisement